MATLAB: How do i plot a surface of a vector

3d plotsvector

x=(0:0.25:a);
y=(-b/2:0.25:b/2)';
[xx,yy]=meshgrid(x,y);
zz=0;
for m=1:2:7
zz=zz+(4*q0*a^4/(3.14^5*m^5*D))*sin(m*3.14*x./a);
end
figure
subplot(2,2,1)
surface(xx,yy,zz)
error shown is that 'z' can not be a constant or a vector. what other function can be used to plot this surface and how?

Best Answer

x=(0:0.25:a);
y=(-b/2:0.25:b/2)';
[xx,yy]=meshgrid(x,y);
zz = zeros(size(xx)) ;
for i = 1:size(xx,1)
for j = 1:size(xx,2)
zz(i,j) = (4*q0*a^4/(3.14^5*m^5*D))*sin(m*3.14*xx(i,j)./a);
end
end
figure
surface(xx,yy,zz)