4-1 ?本??維繪???

mesh M surf OTתŶøϪ򥻫OAmesh ieX骺uϡv]Mesh Plots^Asurf hieX骺uϡv]Surface Plots^A̲ͪϧγ|̰צӦPCCUCdҵeX@ӤGx}ϡ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 br ylabel('Y b = row index'); % Y br %colormap(zeros(1,3)); % H¦e{

bWzdҤAX bx} z ޡAY bhCޡAyܻAbWzϧΤA x = j B y = i ɡAҹ׬O z(i, j)AiHҦpUG

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 br ylabel('Y b = row index'); % Y br 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'); % ܦmC end end %colormap(zeros(1,3)); % H¦e{

YnNP x yЩM y yг@ֵeXӡA٬OiHϥ mesh OAҦpڭ̥iHeX $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 Ox} zz = xx.*yy; % pƭ zzA]Ox} 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

bWzdҤAmeshgrid @άO x y ]Vq^ ǪlI ]Grid Points^AX xx yy]x}^AONlI x yФ y yСC

bUCdҤAڭ̨ϥ linspace Ӳ͸KơAHKeXѨ $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 2525 x} zz = xx.*exp(-xx.^2-yy.^2); % pƭȡAzz ]O 2525 x} mesh(xx, yy, zz); % eX %colormap(zeros(1,3)); % H¦e{

surf M mesh OΪkAͪϧά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 2525 x} zz = xx.*exp(-xx.^2-yy.^2); % zz ]O 252 x} surf(xx, yy, zz); % eX馱 colormap('default') % C^w]

FKեøϡAMATLAB ѤF@ peaks ơAiͤ@ӥWYPA]tFTӧjI]Local Maxima^ΤTӧpI]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} $$

neXƪ̧֤kAYOb MATLAB ROJ peaksAioUC{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 OIAAHUؤPkiøϡAӸ`iѡuhelp peaksvӬduW䴩C

meshz ON[WuȡvΡuRxvĪGG

Example 7: 04-Tø/plotxyz03.m[x, y, z] = peaks; meshz(x,y,z); axis tight;

Hint
bWҤAaxis tight|N϶bb xByBz VdwϧθƦb xByBz VjȤηpȡA]|ϹϧΡ뺡ӹ϶bCϥΡuaxis([-inf, inf, -inf, inf, -inf, inf])viHFۦPĪGC

waterfall Oib x V y VͤyĪGG

Example 8: 04-Tø/plotxyz04.m[x, y, z] = peaks; waterfall(x,y,z); axis tight;

meshc iPɵeXϻPuuv]Contours^G

Example 9: 04-Tø/plotxyz05.m[x, y, z] = peaks; meshc(x, y, z); axis tight;

surfc iPɵeXϻPuA contourBcontourfBcontour3 OhieXPe{覡uAiԨĤuSϧΡvC

plot3 OieXTתŶuG

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); % eX tsin(t),tcos(t),t u

iPɵeXTתŶuG

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ɵeu

pGJ޼ƬOTӤjpۦPx} xByBzA plot3 |̧ǵeXCӦVqbTתŶҹuApUG

Example 12: 04-Tø/plotxyz08.m[x, y] = meshgrid(-2:0.1:2); z = y.*exp(-x.^2-y.^2); plot3(x, y, z);

bWҤAҦIݬOblIWAMATLAB ~ھڨCIרӧ@ϡCpGҵIblIWAڭ̥ݥ griddata OӶi椺kHͮlIAҦpG

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 IX [X, Y] = meshgrid(-3:0.1:3); Z = griddata(x, y, z, X, Y, 'cubic'); % cubic tki椺t meshc(X, Y, Z); hold on plot3(x, y, z, '.', 'MarkerSize', 16); % ޥX 100 Ө hold off axis tight

䤤 xByBz NI]ΨI^A XBYBZ hNھڸIi椺kұo쪺lIAHeXWϡC󦱽uΦAiѨѩnf@uMATLAB {]pGigvĤEutkvC

HUO򥻤TøϫOCG

OO
mesh, ezmesh
meshc, ezmeshc ϥ[Wu
meshz ϥ[Wȡ]ΡRO^
surf, ezsurf
surfc, ezsurfc ϥ[Wu
surfl ϥ[W
u plot3, ezplot3 馱u
C surface surf Ψ쪺CO
line3 plot3 Ψ쪺CO
u contour, ezcontour Wu
contour3 Ŷu
v pcolor bGHCܦ

pGڭ̥uOnܧ֦a˵@Ө㦳GӿJƪϧΡANiHϥ ezmesh άO ezsurf ӧֳtaeXƪϧΡAҦpG

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)');

Qo²檺ƥiHͦpaH


MATLAB{]pGJg