
rectangular domain. The subsequent 2D plot of
X
X and
Y
Y shows
how the grid is sampled.
Now, we should evaluate the
Z
Z at each pair of the grid and generate the
surface plot. This is done with the following code:
Matlab’s command:
>> 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');
>> figure(2); surf(X,Y,Z); xlabel('x'); ylabel('y'); zlabel('Z');
Matlab’s response:
-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
Comentarios a estos manuales