## 4-1 ?ºæœ¬?„ä?ç¶­ç¹ª?–æ?ä»?

mesh ©M surf ¬O¤T«×ªÅ¶¡¥ßÅéÃ¸¹Ïªº°ò¥»«ü¥O¡Amesh ¥iµe¥X¥ßÅéªº¡uºôª¬¹Ï¡v¡]Mesh Plots¡^¡Asurf «h¥iµe¥X¥ßÅéªº¡u¦±­±¹Ï¡v¡]Surface Plots¡^¡A¨âªÌ²£¥Íªº¹Ï§Î³£·|¨Ì°ª«×¦Ó¦³¤£¦PÃC¦â¡C¤U¦C½d¨Òµe¥X¤@­Ó¤Gºû¯x°}ªº¥ßÅéºôª¬¹Ï¡G

Example 1: 04-¤Tºû¥ßÅéÃ¸¹Ï/plotxyz001.mz = [0 2 1; 3 2 4; 4 4 4; 7 6 8]; mesh(z); xlabel('X ¶b = column index'); % X ¶bªº»¡©ú¤å¦r ylabel('Y ¶b = row index'); % Y ¶bªº»¡©ú¤å¦r %colormap(zeros(1,3)); % ¥H¶Â¦â§e²{

¦b¤W­z½d¨Ò¤¤¡AX ¶b¹ïÀ³¨ì¯x°} z ªºª½¦æ¯Á¤Þ¡AY ¶b«h¹ïÀ³¨ì¾î¦C¯Á¤Þ¡A´«¥y¸Ü»¡¡A¦b¤W­z¹Ï§Î¤¤¡A·í x = j ¥B y = i ®É¡A©Ò¹ïÀ³ªº°ª«×¬O z(i, j)¡A¥i¥HÅçÃÒ¦p¤U¡G

Example 2: 04-¤Tºû¥ßÅéÃ¸¹Ï/plotxyz002.mz = [0 2 1; 3 2 4; 4 4 4; 7 6 8]; mesh(z); xlabel('X ¶b = column index'); % X ¶bªº»¡©ú¤å¦r ylabel('Y ¶b = row index'); % Y ¶bªº»¡©ú¤å¦r for i=1:size(z,1) for j=1:size(z,2) h=text(j, i, z(i,j), num2str(z(i, j))); % ¼Ð¥Ü¦±­±°ª«× set(h, 'hori', 'center', 'vertical', 'bottom', 'color', 'r'); % §ïÅÜ¦ì¸m¤ÎÃC¦â end end %colormap(zeros(1,3)); % ¥H¶Â¦â§e²{

­Y­n±N»P¦±­±¹ïÀ³ªº x ®y¼Ð©M y ®y¼Ð³£¤@¨Öµe¥X¨Ó¡AÁÙ¬O¥i¥H¨Ï¥Î mesh «ü¥O¡A¨Ò¦p§Ú­Ì¥i¥Hµe¥X¦±­± $z=xy$ ¦b $x \in [3, 6]$ ¤Î $y \in [5, 9]$ ªººôª¬¹Ï¡G

Example 3: 04-¤Tºû¥ßÅéÃ¸¹Ï/plotxyz011.mx = 3:6; y = 5:9; [xx, yy] = meshgrid(x, y); % xx ©M yy ³£¬O¯x°} zz = xx.*yy; % ­pºâ¨ç¼Æ­È zz¡A¤]¬O¯x°} subplot(2,2,1); mesh(xx); title('xx'); axis tight subplot(2,2,2); mesh(yy); title('yy'); axis tight subplot(2,2,3); mesh(xx, yy, zz); title('zz ¹ï xx ¤Î yy §@¹Ï'); axis tight

¦b¤W­z½d¨Ò¤¤¡Ameshgrid ªº§@¥Î¬O²£¥Í x ¤Î y ¡]§¡¬°¦V¶q¡^ ¬°°ò·Çªº®æ¤lÂI ¡]Grid Points¡^¡A¨ä¿é¥X¬° xx ¤Î yy¡]§¡¬°¯x°}¡^¡A¤À§O¥Nªí®æ¤lÂIªº x ®y¼Ð¤Î y ®y¼Ð¡C

¦b¤U¦C½d¨Ò¤¤¡A§Ú­Ì¨Ï¥Î linspace ¨Ó²£¥Í¸û±K¶°ªº¸ê®Æ¡A¥H«Kµe¥X¥Ñ¨ç¼Æ $z=xe^{-x^2-y^2}$ §Î¦¨ªº¥ßÅéºôª¬¹Ï¡G

Example 4: 04-¤Tºû¥ßÅéÃ¸¹Ï/plotxyz01.mx = linspace(-2, 2, 25); % ¦b x ¶b [-2,2] ¤§¶¡¨ú 25 ÂI y = linspace(-2, 2, 25); % ¦b y ¶b [-2,2] ¤§¶¡¨ú 25 ÂI [xx, yy] = meshgrid(x, y); % xx ©M yy ³£¬O 25¡Ñ25 ªº¯x°} zz = xx.*exp(-xx.^2-yy.^2); % ­pºâ¨ç¼Æ­È¡Azz ¤]¬O 25¡Ñ25 ªº¯x°} mesh(xx, yy, zz); % µe¥X¥ßÅéºôª¬¹Ï %colormap(zeros(1,3)); % ¥H¶Â¦â§e²{

Example 5: 04-¤Tºû¥ßÅéÃ¸¹Ï/plotxyz02.mx = linspace(-2, 2, 25); % ¦b x ¶b [-2,2] ¤§¶¡¨ú 25 ÂI y = linspace(-2, 2, 25); % ¦b y ¶b [-2,2] ¤§¶¡¨ú 25 ÂI [xx,yy] = meshgrid(x, y); % xx ©M yy ³£¬O 25¡Ñ25 ªº¯x°} zz = xx.*exp(-xx.^2-yy.^2); % zz ¤]¬O 25¡Ñ2 ªº¯x°} surf(xx, yy, zz); % µe¥X¥ßÅé¦±­±¹Ï colormap('default') % ÃC¦â§ï¦^¹w³]­È

¬°¤F¤è«K´ú¸Õ¥ßÅéÃ¸¹Ï¡AMATLAB ´£¨Ñ¤F¤@­Ó peaks ¨ç¼Æ¡A¥i²£¥Í¤@­Ó¥W¥Y¦³­Pªº¦±­±¡A¥]§t¤F¤T­Ó§½³¡·¥¤jÂI¡]Local Maxima¡^¤Î¤T­Ó§½³¡·¥¤pÂI¡]Local Minima¡^¡A¨ä¤èµ{¦¡¬°¡G $$z=3(1-x)^2e^{-x^2-(y+1)^2}-10(\frac{x}{5}-x^3-y^5)e^{-x^2-y^2}-\frac{1}{3}e^{-(x+1)^2-y^2}$$

Example 6: 04-¤Tºû¥ßÅéÃ¸¹Ï/peaks01.mpeaks 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)

Example 7: 04-¤Tºû¥ßÅéÃ¸¹Ï/plotxyz03.m[x, y, z] = peaks; meshz(x,y,z); axis tight;

Hint
ƒ¨ ¦b¤W¨Ò¤¤¡A¡§axis tight¡¨·|±N¹Ï¶b¦b x¡By¡Bz ¤è¦Vªº½d³ò©w¬°¹Ï§Î¸ê®Æ¦b x¡By¡Bz ¤è¦Vªº·¥¤j­È¤Î·¥¤p­È¡A¦]¦¹·|¨Ï¹Ï§Î¡§¶ëº¡¡¨¾ã­Ó¹Ï¶b¡C¨Ï¥Î¡uaxis([-inf, inf, -inf, inf, -inf, inf])¡v¥i¥H¹F¨ì¬Û¦Pªº®ÄªG¡C

waterfall «ü¥O¥i¦b x ¤è¦V©Î y ¤è¦V²£¥Í¤ô¬y®ÄªG¡G

Example 8: 04-¤Tºû¥ßÅéÃ¸¹Ï/plotxyz04.m[x, y, z] = peaks; waterfall(x,y,z); axis tight;

meshc ¥i¦P®Éµe¥Xºôª¬¹Ï»P¡uµ¥°ª½u¡v¡]Contours¡^¡G

Example 9: 04-¤Tºû¥ßÅéÃ¸¹Ï/plotxyz05.m[x, y, z] = peaks; meshc(x, y, z); axis tight;

plot3 «ü¥O¥iµe¥X¤T«×ªÅ¶¡¤¤ªº¦±½u¡G

Example 10: 04-¤Tºû¥ßÅéÃ¸¹Ï/plotxyz06.mt = linspace(0,20*pi, 501); % ¦b 0 ¤Î 20*pi ¤¤¶¡¨ú 501 ÂI plot3(t.*sin(t), t.*cos(t), t); % µe¥X tsin(t),tcos(t),t ªº¦±½u

¥ç¥i¦P®Éµe¥X¨â±ø¤T«×ªÅ¶¡¤¤ªº¦±½u¡G

Example 11: 04-¤Tºû¥ßÅéÃ¸¹Ï/plotxyz07.mt = linspace(0, 10*pi, 501); plot3(t.*sin(t), t.*cos(t), t, t.*sin(t), t.*cos(t), -t); % ¦P®Éµe¨â±ø¦±½u

Example 12: 04-¤Tºû¥ßÅéÃ¸¹Ï/plotxyz08.m[x, y] = meshgrid(-2:0.1:2); z = y.*exp(-x.^2-y.^2); plot3(x, y, z);

Example 13: 04-¤Tºû¥ßÅéÃ¸¹Ï/plotxyz09.mx = 6*rand(100,1)-3; % x ¬°¤¶©ó [-3, 3] ªº 100 ÂI¶Ã¼Æ y = 6*rand(100,1)-3; % y ¬°¤¶©ó [-3, 3] ªº 100 ÂI¶Ã¼Æ z = peaks(x, y); % z ¬° peaks «ü¥O²£¥Íªº 100 ÂI¿é¥X [X, Y] = meshgrid(-3:0.1:3); Z = griddata(x, y, z, X, Y, 'cubic'); % ¥Î cubic ¤º®tªk¶i¦æ¤º®t meshc(X, Y, Z); hold on plot3(x, y, z, '.', 'MarkerSize', 16); % ±Þ¥X 100 ­Ó¨ú¼Ë hold off axis tight

¥H¤U¬O°ò¥»¤Tºû¥ßÅéÃ¸¹Ï«ü¥Oªº¦Cªí¡G

ºôª¬¹Ï mesh, ezmesh ¥ßÅéºôª¬¹Ï
meshc, ezmeshc ºôª¬¹Ï¥[¤Wµ¥°ª½u
¦±­±¹Ï surf, ezsurf ¥ßÅé¦±­±¹Ï
surfc, ezsurfc ¦±­±¹Ï¥[¤Wµ¥°ª½u
surfl ¦±­±¹Ï¥[¤W¥ú·½
¦±½u¹Ï plot3, ezplot3 ¥ßÅé¦±½u¹Ï
§C¶¥¨ç¼Æ surface surf ¥Î¨ìªº§C¶¥«ü¥O
line3 plot3 ¥Î¨ìªº§C¶¥«ü¥O
µ¥°ª½u contour, ezcontour ¥­­±¤Wªºµ¥°ª½u
contour3 ªÅ¶¡¤¤ªºµ¥°ª½u
¼v¹³ªí¥Ü pcolor ¦b¤Gºû¥­­±¤¤¥HÃC¦âªí¥Ü¦±­±ªº°ª«×