Page 71 - MATLAB an introduction with applications
P. 71
56 ——— MATLAB: An Introduction with Applications
>> y=2:0.1:8;
>> [x,y]=meshgrid(x,y);
.
>> z=2*x*y^2 /(x^2+y^2);
>> mesh(x,y,z)
>> xlabel(‘x’); ylabel(‘y’); zlabel(‘z’)
>> surf(x,y,z)
>> xlabel(‘x’); ylabel(‘y’); zlabel(‘z’)
10
5
0
–5 x
8
6 4 6
4 2
2 –2 0
Fig. E1.13 (a)
10
5
Z
0
–5
8
6 4 6
4 2
2 –2 0
Fig. E1.13 (b)
Example E1.14: Plot the function = 2 − 1.5 x 2 +y 2 sin( )cos(0.5 ) over the domain 4−≤ x ≤ 4 and 4 ≤ 4
x
z
y
−≤ y
using Table 1.30.
(a) Mesh plot
(b) Surface plot
(c) Mesh curtain plot
(d) Mesh and contour plot
(e) Surface and contour plot
F:\Final Book\Sanjay\IIIrd Printout\Dt. 10-03-09