2one
2one

Reputation: 1085

Matlab: meshgrid and surf (3D plot)

I am trying to generate a 3D surface plot for x,y,z data using surf():

[x,y] = meshgrid(0.5:0.5:25, 0.5:0.5:45);
Z=(tand(y/2)*(1.84+x))*2;

but I get the following error:

Error using * Inner matrix dimensions must agree.

Upvotes: 0

Views: 370

Answers (1)

Zoltan Csati
Zoltan Csati

Reputation: 699

Use the element-wise product:

Z=(tand(y/2).*(1.84+x))*2;
surf(x,y,Z);

Upvotes: 3

Related Questions