
-2
-1.5
-1
-0.5
0
0.5
1
1.5
2
-4
-2
0
2
4
-6
-4
-2
0
2
4
6
x
y
z
Comments:
Creating the 3D mesh and a 3D surface. The function is not smooth
because the dense of the
x
x and
y
y was too low.
With the above code, a 3D mesh and a 3D surface is created. It is apparent
that the surfaces are not smooth because the original density of
x
x and
y
y
vectors was too low. In the following, we re-create the mesh and surface with
higher densities.
Matlab’s command:
>> x=-2:0.25:2; y=-4:0.5:4; [X,Y]=meshgrid(x,y);
>> Z =3*(1-X).^2.*exp(-(X.^2) - (Y+1).^2)- ...
10*(X/5-X.^3-Y.^5).*exp(-X.^2-Y.^2)-1/3*exp(-(X+1).^2-Y.^2);
>> figure(1); mesh(X,Y,Z); xlabel('x'); ylabel('y'); zlabel('Z'); title('Peaks')
>> figure(2); surf(X,Y,Z); xlabel('x'); ylabel('y'); zlabel('Z'); title('Peaks');
Commentaires sur ces manuels