Borrar filtros
Borrar filtros

Plotting y=sin x in 3d

25 visualizaciones (últimos 30 días)
Amril Luqman
Amril Luqman el 8 de Mayo de 2021
Comentada: Amril Luqman el 8 de Mayo de 2021
I want to plot y=sin x,0≤ x ≤ 2π, with 300 linear space points interval in 3D. Im kinda new to matlab, so i the read help center to learn how to do plot 3d graph. Can someone help me check it if it correct or not?
x=linspace(0,2*pi,300);
[x,y]=mehsgrid(x);
z=sin(x);
surf(x,y,z)

Respuesta aceptada

DGM
DGM el 8 de Mayo de 2021
What did you get when you ran it? Whether it's "right" depends on what the goal is.
% this plots the surface over both x and y
% z is invariant over y
x = linspace(0,2*pi,300);
[x,y]=meshgrid(x); % spelled right
z = sin(x);
surf(x,y,z)
% this plots z for y=0
x = linspace(0,2*pi,300);
y = zeros(size(x));
z = sin(x);
plot3(x,y,z)
Depends what you want.
  1 comentario
Amril Luqman
Amril Luqman el 8 de Mayo de 2021
Ohh.. i want the graph to looks like the second one. Thank you very much for the help!!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.

Productos


Versión

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by