Hi,

I'm having a problem with the mesh & surf commands in Matlab. I am trying to plot a 3D contour, Z, in a limited area.

Using plot3 as follows works fine:

Code:

for theta1 = -0.5:0.05:2.5
for theta2 = -0.5:0.05:2.5
Z = ((0.1150 * sin(theta1) * cos(theta2) * 9.81 + 0.1150 * cos(theta1) * sin(theta2) * 9.81 + 0.3990 * sin(theta1) * g) ^ 2 / 20) + (0.00013)
plot3(theta1,theta2,Z);
end
end

But as mesh is clearer I'd prefer to use that.

However when I try following the Matlab example my plot seems to ignore one of my input arguments producing a Z matrix where all the rows are identical? I've spent quite a bit of time on this and just can't get the bottom of it. I'd realy appreciate any suggestions...

Here is my code:

Code:

[theta1,theta2] = meshgrid(-0.5:0.05:2.5);
Z = ((0.1150 * sin(theta1) * cos(theta2) * 9.81 + 0.1150 * cos(theta1) * sin(theta2) * 9.81 + 0.3990 * sin(theta1) * g) ^ 2 / 20) + (0.00013)
mesh(theta1,theta2,Z);

Strangely ezmesh seems to work fine but I'd like to know why mesh doesn't like my equation (which plot3 does like).

Many Thanks,

Ad