Example: dental hygienist

MATLAB 二維繪圖 - cc.ntut.edu.tw

MATLAB nplot : n x y x = linspace(0, 2*pi);% 0 2 100 y = sin(x);% x plot(x, y);% (Index) n x y plot n x = linspace(0, 2*pi);% 0 2 100 plot(x, sin(x), x, cos(x), x, sin(x)+cos(x)); % plot(x, sin(x)); hold on; plot(x, cos(x)); hold off; y plotyyx y semilogyx y semilogxx y (Logarithmic Scale)loglogx y (Linear Scale) plot nsemilogx n x x = linspace(0, 8*pi);% 0 8 100 semilogx(x, sin(x)); % x nplotyy n y x = linspace(0, 2*pi);% 0 2 100 y1 = sin(x); y2 = exp(-x); ploty

基本二維繪圖指令 plotyy 畫出兩個刻度不同的y軸 semilogy x 軸為線性刻度,y 軸為對數刻度 semilogx x 軸為對數刻度,y 軸為線性刻度

Tags:

  Ntut

Information

Domain:

Source:

Link to this page:

Please notify us if you found a problem with this document:

Other abuse

Advertisement

Transcription of MATLAB 二維繪圖 - cc.ntut.edu.tw

1 MATLAB nplot : n x y x = linspace(0, 2*pi);% 0 2 100 y = sin(x);% x plot(x, y);% (Index) n x y plot n x = linspace(0, 2*pi);% 0 2 100 plot(x, sin(x), x, cos(x), x, sin(x)+cos(x)); % plot(x, sin(x)); hold on; plot(x, cos(x)); hold off; y plotyyx y semilogyx y semilogxx y (Logarithmic Scale)loglogx y (Linear Scale) plot nsemilogx n x x = linspace(0, 8*pi);% 0 8 100 semilogx(x, sin(x)); % x nplotyy n y x = linspace(0, 2*pi);% 0 2 100 y1 = sin(x); y2 = exp(-x); plotyy(x, y1, x, y2).

2 % y y1, y2 nplot n n plot(x, y, CLM )nC (Colors) nL (Line Styles) nM (Markers)n x = 0 :4*pi;y = sin(x); plot(x, y, k:diamond )% k % diamond % (1,1,0) (Yellow)y(1,1,1) w(1,0,0) (Red)r(1,0,1) (Magenta)m(0,0,0) (Black)k(0,1,0) (Green)g(0,1,1) (Cyan)c(0,0,1) (Blue)bRGB Plot plot -. -- ( ) - plot plot pentagram square < > V diamond hexagram ^ * X + O plot nplot n axis n axis([xmin, xmax, ymin, ymax])nxmin, xmax x nymin, ymax y grid box n box off box on grid off grid on n y 0 1 x = 0 :4*pi;y = sin(x);plot(x, y);axis([-inf, inf, 0, 1]);% y 0 1 grid on.

3 % inf ( x ) n gtext text legendz ( ) zlabely ylabelx xlabel title n x = 0 :2*pi; y1 = sin(x); y2 = exp(-x); plot(x, y1, '--*', x, y2, ':o'); xlabel('time'); ylabel('valuesof sin(t) and exp(-x)') title('Function Plots of sin(t) and exp(-x)'); legend('sin(t)','exp(-x)'); of sin(t) and exp(-x)Function Plots of sin(t) and exp(-x)sin(t)exp(-x)ntext n text(x, y, string ) nx y nstring x = 0 :2*pi;plot(x, sin(x), x, cos(x));text( , 0, 'sin(x)')text( *pi+ , 0, 'cos(x)') (x)cos(x)ngtext n gtext( string )n string ngtext nsubplotn ( )n subplot(m, n, p)n m n n plot p np n x = 0 :4*pi; subplot(2, 2, 1); plot(x, sin(x));% subplot(2, 2, 2).

4 Plot(x, cos(x));% subplot(2, 2, 3); plot(x, sin(x).*exp(-x/5));% subplot(2, 2, 4); plot(x, x.^2);% (2,2,1)subplot(2,2,3)subplot(2,2,2)subpl ot(2,2,4) -errorbarnerrorbar: n y 20% x = linspace(0,2*pi,30);% 0 2 30 y = sin(x);e = y* ;errorbar(x,y,e)% -fplotnfplot: n fplot('sin(1/x)', [ ]);% [ ]