MATLAB: Hello everyone, I wrote a code for computing an equation and plot in 3-D (surf)? but it didn’t give me a right answer! what is the problem? Also the plot is attached.

3d plotssurf

w3=0:0.1:5;
t=0:0.01:5;
w=107.36; d=150; x=410;
[a,b]=meshgrid(w3,t);
z=abs(((4.22*(10.^-3))*((a).^2)/((w.^2)-(a.^2))))*sin((pi*d)/820)*sin((pi*x)/820)*sin((a).*b);
surf(a,b,z)
The error is:
Warning: Rank deficient, rank = 1, tol = 9.150206e-09.
> In vibrationalresponse3d (line 15)

Best Answer

When dealing with arrays, unless you specifically intend too do matrix operations, always use element-wise operations (the dot operator).
Try this:
w3=0:0.1:5;
t=0:0.01:5;
w=107.36; d=150; x=410;
[a,b]=meshgrid(w3,t);
z=abs((4.22E-3)*(a.^2)./((w.^2)-(a.^2))).*sin((pi*d)/820).*sin((pi*x)/820).*sin(a.*b);
figure
surf(a,b,z, 'EdgeColor','none')
producing:
1HELLO~1.PNG
Also, eliminating the edge line color makes the patch faces visible.
Related Question