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²{

surf ©M mesh «ü¥Oªº¥ÎªkÃþ¦ü¡A¦ý²£¥Íªº¹Ï§Î¬O¥ßÅ馱­±¹Ï¡G

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} $$

­nµe¥X¦¹¨ç¼Æªº³Ì§Ö¤èªk¡A§Y¬O¦b MATLAB ©R¥Oµøµ¡ª½±µÁä¤J peaks¡A¥i±o¨ì¤U¦C¤èµ{¦¡»P¹Ï§Î¡G

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)

§Ú­Ì¥ç¥i¹ï peaks «ü¥O¨úÂI¡A¦A¥H¦UºØ¤£¦P¤èªk¶i¦æø¹Ï¡A¬ÛÃö²Ó¸`¥i¥Ñ¡uhelp peaks¡v¦Ó¬d¨ì½u¤W¤ä´©¡C

meshz «ü¥O¦³±N¦±­±¥[¤W¡u³ò¸È¡v©Î¡u»R¥x¡vªº®ÄªG¡G

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;

surfc ¥i¦P®Éµe¥X¦±­±¹Ï»Pµ¥°ª½u¡A¦Ó contour¡Bcontourf¡Bcontour3 µ¥«ü¥O«h¥iµe¥X¤£¦P§e²{¤è¦¡ªºµ¥°ª½u¡A¥i¸Ô¨£²Ä¤­³¹¡u¯S®í¹Ï§Î¡vªº»¡©ú¡C

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

¦pªG¿é¤J¤Þ¼Æ¬O¤T­Ó¤j¤p¬Û¦Pªº¯x°} x¡By¡Bz¡A¨º»ò plot3 ·|¨Ì§Çµe¥X¨C­Ó¦æ¦V¶q¦b¤T«×ªÅ¶¡©Ò¹ïÀ³ªº¦±½u¡A¦p¤U¡G

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

¦b¤W¨Ò¤¤¡A©Ò¦³ªº¸ê®ÆÂI³£¥²»Ý¬O¦b®æ¤lÂI¤W¡AMATLAB ¤~¯à®Ú¾Ú¨CÂIªº°ª«×¨Ó§@¹Ï¡C¦pªG©Òµ¹ªº¸ê®ÆÂI¤£¦b®æ¤lÂI¤W¡A§Ú­Ì¥²»Ý¥ý¥Î griddata «ü¥O¨Ó¶i¦æ¤º´¡ªk¥H²£¥Í®æ¤lÂI¡A¨Ò¦p¡G

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

¨ä¤¤ x¡By¡Bz ¥Nªí¸ê®ÆÂI¡]©Î¨ú¼ËÂI¡^¡A¦Ó X¡BY¡BZ «h¥Nªí®Ú¾Ú¸ê®ÆÂI¶i¦æ¤º´¡ªk©Ò±o¨ìªº®æ¤lÂI¡A¥Hµe¥X¤W­±ªººôª¬¹Ï¡C¦³Ãö©ó¦±½u¤Î¦±­±ªº¤º´¡¡A¥i°Ñ¨£¥»®Ñ©n©f§@¡uMATLAB µ{¦¡³]­p¡G¶i¶¥½g¡v²Ä¤E³¹¡u¤º®tªk¡v¡C

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

Ãþ§O«ü¥O»¡©ú
ºôª¬¹Ï mesh, ezmesh ¥ßÅéºôª¬¹Ï
meshc, ezmeshc ºôª¬¹Ï¥[¤Wµ¥°ª½u
meshz ºôª¬¹Ï¥[¤W¡§³ò¸È¡¨¡]©Î¡§»R»O¡¨¡^
¦±­±¹Ï 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¦âªí¥Ü¦±­±ªº°ª«×

¦pªG§Ú­Ì¥u¬O­n«Ü§Ö¦aÀ˵ø¤@­Ó¨ã¦³¤G­Ó¿é¤Jªº¨ç¼Æªº¹Ï§Î¡A´N¥i¥H¨Ï¥Î ezmesh ©Î¬O ezsurf µ¥¨Ó§Ö³t¦aµe¥X¨ç¼Æªº¦±­±¹Ï§Î¡A¨Ò¦p¡G

Example 14: 04-¤Tºû¥ßÅéø¹Ï/plotxyz091.msubplot(2,2,1); ezmesh('sin(x)/x*sin(y)/y'); subplot(2,2,2); ezsurf('sin(x*y)/(x*y)'); subplot(2,2,3); ezmeshc('sin(x)/x*sin(y)/y'); subplot(2,2,4); ezsurfc('sin(x*y)/(x*y)');

«ÜÃø·Q¹³³o¨Ç²³æªº¨ç¼Æ¥i¥H²£¥Í¦p¦¹½ÆÂøªº¦±­±§a¡H


MATLABµ{¦¡³]­p¡G¤Jªù½g