NLed
NLed

Reputation: 1865

How to convert this into a 3D mesh plot?

I have the following code :

a=7
f=10
T=1/f;
v=40
wl=v/f;
x1=1;
x2=30
step=0.01

t=x1:step:x2;
x=x1:step:x2;
y=a*sind(2*pi*f*(t+(x*T)/wl)); 
h=plot(x,y);

I tried h=plot3(x,y,t) but the line itself remains in 2D .. Should I convert this into a matrix ?

Upvotes: 0

Views: 204

Answers (1)

Oleg
Oleg

Reputation: 10676

Create a grid of points and then use mesh():

[x,t] = meshgrid(x,t);
y     = a*sind(2*pi*f*(t+(x*T)/wl)); 
mesh(y)

Upvotes: 1

Related Questions