% Example of mesh function for plotting surfaces % Author: F. P. Schloerb % define regular x,y grid x = -100:100; y = -100:100; % compute the value of "z" for each point in x,y grid % this is sin(r)/r or "sinc" function for i=1:length(x) for j=1:length(y) r = sqrt(x(i)*x(i)+y(j)*y(j)); if(r == 0) z(i,j) = 1; % note special handling for r=0! else z(i,j) = sin(0.2*r)/(0.2*r); end end end % call the mesh function to plot the surface mesh(x,y,z) % label the plot xlabel('X') ylabel('Y') zlabel('Z') title('Mesh plot example - sinc function')