4 MATLAB 1 visualization MATLAB 2 Octave gnuplot Octave copyright c 2004 Tatsuya Kitamura / All rights reserved. 35
4 4.1 1 1 y =2x x 5 5 x y plot 4.1 Figure No. 1 figure window >> x=-5:5;ψ >> y=2*x;ψ >> plot(x,y)ψ 4.1: y =2x ( 5 x 5) plot plot MATLAB close MAT Octave closeplot OCT X plot(y) X 1 2... 11 X X Y 36
4.2. >> x2=-3:3;ψ >> y2=2*x+1;ψ >> plot(x,y,x2,y2)ψ >> x=-5:-5;ψ >> Y=2*x; Y=[Y; 2*x+1]; Y=[Y; 2*x+2];ψ >> plot(x,y)ψ 4.2 grid linegrid MATLAB grid on grid off Octave grid "on" grid "off" MATLAB grid toggle 2 grid grid Octave grid Octave grid "on" replot OCT octave:4> grid "on"ψ octave:5> replotψ grid off replot OCT 4.3 MATLAB Octave plot 37
4 POINT plot 1 plot(x, Y, ) plot(x 1, Y 1,, X 2, Y 2,,...) MATLAB Octave 4.3.1 MATLAB MATLAB 4.1 4.2 4.3 MATLAB dotted green g : >> plot(x,y, g: )ψ solid solid - cyan cs >> plot(x,y, cs )ψ -. 4.2 >> plot(x,y, cs-. )ψ TRY 38
4.3. 4.1: MATLAB y yellow g green m magenta b blue c cyan w white r red k black 4.2: MATLAB - solid : dotted -. dashdot -- dashed 4.3: MATLAB. v o ^ x < < + + > > * p s 4 h 6 d 10 8 6 4 2 0 2 4 6 8 10 5 4 3 2 1 0 1 2 3 4 5 4.2: x=-5:5; y=2*x; plot(x,y, cs-. ); grid on 39
4 4.3.2 Octave Octave 4.4 4.5 4.6 dots plot style green g. lines plot style - octave:1> x=-5:5; y=2*x;ψ octave:2> plot(x,y, g. )ψ 4.4 plot(x,y, 2. ) cyan c3 octave:3> plot(x,y, c3 )ψ plot(x,y, 53 ) linespoints plot style -@ dots plot style octave:4> plot(x,y, c3-@. )ψ Octave gnuplot gplot OCT Octave 1 4.4: Octave 1 r red 4 m magenta 2 g green 5 c cyan 3 b blue 6 w brown 1, gnuplot, (1999). 40
4.4. 4.5: Octave - lines plot style. dots plot style @ points plot style -@ linespoints plot style ^ impulses plot plot style L steps plot style 4.6: Octave 1 o 4 x 2 + + 5 3 4 6 * TRY Tips plot(x,y, r+- ) plot(x,y, r+,x,y, b- ) 2 plot(x,y, r+,x,y, b-,x,y, y-- ) 4.4 X Y label title 1 y =sin(ω) π 10 sin >> omega=0:pi/10:4*pi;ψ >> plot(omega,sin(omega))ψ X Y xlabel ylabel title 41
4 UNIX MATLAB Windows MATLAB >> xlabel( omega [rad] ); ylabel( y )ψ >> title( sin(omega) )ψ MATLAB L A TEX 2 LATEX 4.7 4.8 ω π y =sin(ω) 4.3 >> xlabel( \omega [rad] ); ylabel( y )ψ >> title( sin(\omega) (0 \leq \omega \leq 4\pi) )ψ 1 sin(ω) (0 ω 4π) 0.8 0.6 0.4 0.2 y 0 0.2 0.4 0.6 0.8 1 0 2 4 6 8 10 12 14 ω [rad] 4.3: Octave 4.2 grid 4.5 Octave MATLAB legend MAT 2 Octave 42
4.5. 4.7: MATLAB L A TEX α \alpha β \beta γ \gamma δ \delta ɛ \epsilon ζ \zeta η \eta θ \theta ϑ \vartheta ι \iota κ \kappa λ \lambda µ \mu ν \nu ξ \xi π \pi ρ \rho σ \sigma ς \varsigma τ \tau υ \upsilon φ \phi χ \chi ψ \psi ω \omega Γ \Gamma \Delta Θ \Theta Λ \Lambda Ξ \Xi Π \Pi Σ \Sigma Υ \Upsilon Φ \hi Ψ \Psi Ω \Omega ϖ \varpi 4.8: MATLAB LATEX \equiv \neq = \cong \approx \oplus \otimes \oslash \int \cap \supset \cup \infty \supseteq \supset \subseteq \subset \rfloor \lfloor \rceil \lceil \langle \rangle \circ \bullet \leftarrow \uparrow \rightarrow \downarrow \diamondsuit \heartsuit \spadesuit \clubsuit \leq \geq R \Re I \Im \times \div ± \pm c \copyright \wedge \vee \in \ni \forall \exists \cdots...\ldots \perp = \cong \neg \surd \sim \partial ℵ \aleph \wp ø \o \nabla \prime Ø \O \mid \leftrightarrow 43
4 legend MAT y =sin(ω) y =cos(ω) L A TEX 4.4 >> omega=0:pi/10:4*pi;ψ >> plot(omega,sin(omega), b,omega,cos(omega), r-- );ψ >> legend( sin(\omega), cos(\omega) );ψ 1 0.8 sin(ω) (0 ω 4π) sin(ω) cos(ω) 0.6 0.4 0.2 y 0 0.2 0.4 0.6 0.8 1 0 2 4 6 8 10 12 14 ω [rad] 4.4: legend off 4.6 1 hold plot hold POINT hold 44
4.7. hold grid hold on hold off Octave grid on off MATLAB hold grid 1 hold hold y =sin(ω) y =cos(ω) >> omega=0:pi/10:4*pi;ψ >> plot(omega,sin(omega), b )ψ >> hold onψ >> plot(omega,cos(omega), r-- )ψ MATLAB clf MAT CLear current Figure Octave clearplot OCT TRY 4.4 y =sin(ω + π 5 ) 4.7 4.4 Y axis 4.4 >> axisψ ans = 0 14-1 1 X X Y Y 4.4 0 ω 4π 1.5 y 1.5 >> axis([0 4*pi -1.5 1.5]);ψ 45
4 1.5 sin(ω) (0 ω 4π) sin(ω) cos(ω) 1 0.5 y 0 0.5 1 1.5 0 2 4 6 8 10 12 ω [rad] 4.5: axis([0 4*pi -1.5 1.5]) 4.5 4.8 figure Figure No. 2 y = x 2 +5 ( 10 x 10) >> x=-10:10;ψ >> figure; plot(x,x.ˆ2+5)ψ figure 1 >> figure(1)ψ >> hold on; plot(x2,y2, g: )ψ 46
4.9. handler gcf MAT Get Current Figure >> gcfψ ans = 1 Figure No. 1 1 TRY figure 4.9 POINT subplot m n k subplot(mnk) subplot(m,n,k) subplot(421) subplot(4,2,1) 4 2 1 4.6 subplot plot 2 >> subplot(211); plot(x1,y1)ψ >> subplot(212); plot(x2,y2)ψ >> subplot(211)ψ >> xlabel( x ); ylabel( y ); title( 1st plot )ψ 47
4 4.6: 4 2 subplot(421) subplot(428) grid hold axis MATLAB cla MAT CLear current Axis clf MAT 2 1 subplot clf MAT >> subplot(211)ψ >> claψ TRY 3 X Y 48
Tips 4.10. 2 2 >> subplot(211); plot(x1,y1)ψ >> subplot(223); plot(x2,y2)ψ >> subplot(224); plot(x3,y3)ψ 4.10 print subplot 4.10.1 UNIX MATLAB print UNIX MATLAB print 4.9 4.9: UNIX MATLAB print -P -f 2 lp1 >> print -Plp1 -f2ψ -P -f GUI File Print toolbar 4.7 4.8 Print 49
4 4.7: 4.8: Print Print 4.10 Print 4.10: Print Paper type Paper orientation Printer Device option Send to File Print Save Page Setup File Page Setup 4.9 Page Setup File Print Preview 50
4.10. 4.9: Page Setup 4.11: Page Setup Orientation Limits Color Size and Position 4.10.2 Windows MATLAB UNIX MATLAB print Windows MATLAB print 4.12 Windows UNIX GUI UNIX 4.12: Windows MATLAB print -dwin -dwinc -dsetup -f 51
4 4.10.3 Octave gset OCT replot OCT PostScript PS ghostscript gset OCT terminal postscript UNIX lpr replot OCT octave:5> gset terminal postscriptψ octave:6> gset output " lpr"ψ octave:7> replotψ X terminal x11 octave:8> gset terminal x11ψ octave:9> gset outputψ gshow OCT terminal terminal x11 octave:10> gshow terminal ψ terminal type is x11 0 gset OCT gshow OCT gnuplot set show PS gnuplot set 4.11 4.11.1 MATLAB print POINT MATLAB print -d MATLAB 4.13 -f print 52
4.11. 4.10.1 GUI -dps -dpsc -dps2 -dpsc2 -deps -depsc -deps2 -depsc2 -djpegnn -dtiff -dmeta -dbitmap -dmfile 4.13: print PostScipt PS PS 2 PS 2 PS Encapsulated PostScript EPS EPS 2 EPS 2 EPS JPEG nn TIFF Metafile Windows bitmap Windows graph01.eps 1 Encapsulated PostScript EPS >> print -deps graph01.eps ψ EPS LATEX >> fname = graph02.eps ;ψ >> print -deps fnameψ -dmeta -dbitmap Windows print -dbitmap graph03.bmp 1 print >> print -dmetaψ Microsoft Word Microsoft PowerPoint MATLAB 53
4 -dmfile MAT M 1 graph04.mat graph04.m >> print -dmfile graph04ψ >> graph04ψ MATLAB MATLAB 54
4.11. 4.11.2 Octave gset OCT replot OCT PS terminal postscript replot OCT octave:11> gset terminal postscriptψ octave:12> gset output "graph04.ps"ψ octave:13> replotψ EPS terminal postscript eps postscript gnuplot set replot OCT octave:14> gset terminal postscript epsψ octave:15> gset output "graph04.eps"ψ octave:16> replotψ X terminal x11 octave:17> gset terminal x11ψ octave:18> gset outputψ gnuplot PS EPS GIF Tgif L A TEX picture gnuplot set 55