I'm trying to graph the function xye^(-(x.^2+y.^2)), and I used both surf and mesh to do so. Below is the code. The problem is the two graphs are different. The surf function seems to have gotten it correct, but the mesh function looks like it graphed the absolute value of the function. Why is there this difference?
clearclcr=100;x1 = linspace(-10,10,r);y2 = linspace(-10,10,r);[x,y] = meshgrid(x1,y2);z=x.*y.*exp(-(x.^2+y.^2));figuresurf(x,y,z)xlabel('x');ylabel('y');zlabel('z');grid onshading interpcolorbarfiguremesh(x,y,z.^2)xlabel('x');ylabel('y');zlabel('z');grid on
Best Answer