MATLABマニュアル(2003)ver5 - Kawamata る.後者のm-ファイルを用いた方法はC や他のプログラム言語と同じようなものである. ここでは,コマンドラインからの入力について説明する.MATLAB を起動すると“”という記号が 表示される.以降,この記号のことを ...

  • Published on
    10-May-2018

  • View
    216

  • Download
    2

Transcript

<ul><li><p> 1</p><p>MATLAB 2003 </p><p>( ) </p><p> WEB </p><p>http://www.mk.ecei.tohoku.ac.jp/dsptext/ </p><p>1. MATLAB </p><p>2. </p><p>3. </p><p>4. m- </p><p>5. </p><p>6. </p><p>7. MATLAB </p><p>8. </p><p>9. 10. Octave(MATLAB) </p><p>MATLAB </p><p>MATLAB Matrix Laboratory</p><p>MATLAB </p><p>MATLAB matlab MATLAB % matlab </p><p>MATLAB MATLAB exit quit &gt;&gt;exit </p><p>MATLAB m-</p></li><li><p> 2</p><p> m- C MATLAB &gt;&gt;&gt;&gt;</p><p> 10+20/2-5*3 /* &gt;&gt;10+20/2-5*3 </p><p> return(enter) ans = </p><p> 5 </p><p> return(enter) ( ) &gt;&gt;(10*(5-3))/2 </p><p>ans = </p><p> 10 </p><p> &gt;&gt;x=3 </p><p>"=" x = </p><p> 3 </p><p> x 3 &gt;&gt;x=3; </p><p>";" &gt;&gt;x+3 </p><p> ans = </p><p> 6 </p><p> &gt;&gt;x=4; </p><p> &gt;&gt;x+3 </p></li><li><p> 3</p><p> ans = </p><p> 7 </p><p>1 2 ()(Ctrl ) p(n) </p><p>&gt;&gt;x </p><p> x = </p><p> 4 </p><p>MATLAB x X &gt;&gt;who </p><p> clear x </p><p> &gt;&gt;clear x </p><p> MATLAB &gt;&gt;sqrt(9) </p><p>ans = </p><p> 3 </p><p> &gt;&gt;sin(pi/6) </p><p>ans = </p><p> 0.5000 </p><p> MATLAB pi &gt;&gt;log10(5) </p></li><li><p> 4</p><p>ans = </p><p> 0.9660 </p><p>( ) help sin &gt;&gt;help sin </p><p> MATLAB i j MATLAB 1i </p><p>&gt;&gt; (3+1i)*(2-3i) </p><p>ans = </p><p> 9.0000-7.0000i </p><p>conj(x) x </p><p> MATLAB MATLAB m n m,n 1 n 1 n [1 3 5 7 9 11] MATLAB &gt;&gt;A=[1 3 5 7 9 11] </p><p>A = </p><p> 1 3 5 7 9 11 </p><p> A[ ] A 3 &gt;&gt;A(3) </p><p>ans = </p><p> 5 </p><p>A &gt;&gt;size(A) </p></li><li><p> 5</p><p>ans = </p><p> 1 6 </p><p> 16 A 1 6 </p><p>A 3 &gt;&gt;A(3)=4; </p><p> 1 C 02 1 &gt;&gt;A=[1 3 5 7 9]; </p><p>&gt;&gt;B=[2 4 6 8 10]; </p><p>&gt;&gt;A+B </p><p>ans = </p><p> 3 7 11 15 19 </p><p>&gt;&gt;B-A </p><p>ans = </p><p> 1 1 1 1 1 </p><p>&gt;&gt;B.*A </p><p>ans = </p><p> 2 12 30 56 90 </p><p>&gt;&gt;A./B </p><p>ans = </p><p> 0.5000 0.7500 0.8333 0.8750 0.9000 </p><p> */.*./ sqrt &gt;&gt;sqrt(A) </p><p>ans = </p><p> 1.0000 1.7321 2.2361 2.6458 3.0000 </p></li><li><p> 6</p><p> x 0, 0.1, 0.2, ..., 3.0, 3.1 sin(x) x 0.1 0 3.1":" &gt;&gt;x=0:0.1:3.1; </p><p> x 0 0.1 3.1 32 1 : : </p><p> 2:5 1 &gt;&gt;z=2:5 </p><p>z = </p><p> 2 3 4 5 </p><p>10:-1:5 x sin(x) </p><p>&gt;&gt;sin(x) </p><p>32 x 32 sin(x) </p><p>3 3 &gt;&gt;A=[1 2 3;4 5 6;7 8 9] </p><p>A = </p><p> 1 2 3 </p><p> 4 5 6 </p><p> 7 8 9 </p><p>";" m n m, n A+B, A-B, A.*B, A./B</p><p> &gt;&gt;A(3,2) </p><p> 3 4 &gt;&gt;size(A) </p><p> &gt;&gt;A=[1 2 3;4 5 6;7 8 9]; </p><p>&gt;&gt;sqrt(A) </p></li><li><p> 7</p><p>ans = </p><p> 1.0000 1.4142 1.7321 </p><p> 2.0000 2.2361 2.4495 </p><p> 2.6458 2.8284 3.0000 </p><p> ones zeros &gt;&gt;ones(3,4)*2 </p><p>ans = </p><p> 2 2 2 2 </p><p> 2 2 2 2 </p><p> 2 2 2 2 </p><p> 2 2 2 2 </p><p> 2 &gt;&gt;A(2,:) </p><p> 3 &gt;&gt;A(:,3) </p><p> "'" &gt;&gt;A' </p><p>ans = </p><p> 1 4 7 </p><p> 2 5 8 </p><p> 3 6 9 </p><p>"*""C*D" C n D n &gt;&gt;C=[1 2;3 4]; </p><p>&gt;&gt;D=[1 2 3;4 5 6]; </p><p>&gt;&gt;C*D </p><p>ans = </p><p> 9 12 15 </p><p> 19 26 33 </p></li><li><p> 8</p><p>m- </p><p>MATLAB m-m-m-</p><p> m-</p><p>UNIX Mule 2 </p><p> v1=[3 5]; % 1 </p><p> v2=[-6 2]; % 2 </p><p> v1*v2' % 1 2 </p><p> 3 m naiseki.m MATLAB m- UNIX MS-DOSWindows </p><p> &gt;&gt;cd </p><p> &gt;&gt;cd m- </p><p> m-</p><p> &gt;&gt;naiseki </p><p> ans = </p><p> -8 </p><p>1 2 v1 v2 %% 3 v2 1 2 2 1 ' 3 ; </p><p>MATLAB </p></li><li><p> 9</p><p> sin m- x=0:0.1:3.1; </p><p>plot(sin(x)) </p><p>m-m-,figure sin x 1 x 1 0 sin(x) 2 x 2 0.1 sin(x) x plot(sin(x)) </p><p> plot(x,sin(x)) </p><p>1 2 x 32 MATLAB </p><p>MATLAB m- x=0:0.1:3.1; </p><p> y1=sin(x); % </p><p> y2=cos(x); % </p><p> hold on % </p><p> plot(x,y1) </p><p> stem(x,y2) </p><p> axis([0 3.1 -1.2 1.2]),grid % </p><p> xlabel('x'),ylabel('y1,y2') % </p><p> hold off </p><p> sin cos </p><p> &gt;&gt;clf </p><p>clf figure hold on stem plot axis axis([ </p><p>]) axis grid","","1 grid xlabel,ylabelxlabel('Time')</p></li><li><p> 10</p><p> &gt;&gt;print </p><p>MATLAB conv </p><p>2 [3 4 -1][3 1 6 2] y y(1)=33 = 9 </p><p>y(2)=31 + 43 = 15 </p><p>y(3)=36 + 41 + (-1)3 = 19 </p><p>y(4)=32 + 46 + (-1)1 = 29 </p><p>y(5)= 42 + (-1)6 = 2 </p><p>y(6)= (-1)2 = -2 A=[3 4 -1]; </p><p> B=[3 1 6 2]; </p><p> y=conv(A,B) </p><p> ans = </p><p> 9 15 19 29 2 -2 </p><p>filter </p><p> X y</p><p> A(1)y(n) = -A(2)y(n-1)-A(3)y(n-2)- ... -A(na+1)y(n-na) </p><p> +B(1)x(n)+B(2)x(n-1)+B(3)x(n-2)+ ... +B(nb+1)x(n-nb) </p><p> A=[1 -0.5]; </p></li><li><p> 11</p><p> B=[0.5]; </p><p> x=[1 zeros(1,10)]; </p><p> y=filter(B,A,x) </p><p> y = </p><p> Columns 1 through 7 </p><p> 0.5000 0.2500 0.1250 0.0625 0.0313 0.0156 0.0078 </p><p> Columns 8 through 11 </p><p> 0.0039 0.0020 0.0010 0.0005 </p><p>freqz </p><p> filter</p><p> A=[1 -0.5]; </p><p> B=[0.5]; </p><p> W=-pi:0.01:pi; </p><p> H=freqz(B,A,W); </p><p> magH=abs(H); </p><p> plot(W,magH); </p><p> H abs </p><p>MATLAB </p><p>("MATLAB ") </p><p> pi </p><p> eps </p><p> + </p></li><li><p> 12</p><p> - </p><p> * </p><p> / </p><p> .* </p><p> ./ </p><p> ^ </p><p> .^ </p><p> == </p><p> ~= </p><p> , = </p><p> &amp; | </p><p> ~ </p><p> : 1:5 , 4:2:20 </p><p> ; </p><p> ... </p><p> % </p><p> .' A.' </p><p> abs abs(x)x </p><p> angle angle(h) h </p><p> axis axis([XMIN XMAX YMIN YMAX]) x y bilinear [NUMd,DENd]=bilinear(NUM,DEN,Fs) z blackman blackman(N)Blackman N boxcar boxcar(N) 1 butter [B,A]=butter(N,Wn)N Butterworth buttord buttord(Wp,Ws,Rp,Rs) Wp Rp [dB] Ws</p><p> Rs [dB] Butterworth N </p><p> ceil ceil(x)x x </p><p> circconv circconv(h,x) h x </p><p> colormap colormap(gray)figure colormap([0 0 0]) </p><p> compose compose(f,g,x,z)Symbolic Math Toolbox f(x) x g(z) </p><p> conv c=conv(a,b) a b </p></li><li><p> 13</p><p> conv2 C=conv2(A, B) A B 2 cos cos(x)x </p><p> cot cot(x)x </p><p> direct </p><p> disp disp(X) X X double double(x)x </p><p> error error('message') </p><p> exp exp(x)x </p><p> fft fft(x) x </p><p> fft2 fft2(X) X 2 fftshift fftshift(x) x </p><p> figure figure figure filter y=filter(b,a,x) X </p><p> filter2 Y=filter2(B,X) B 2 FIR X </p><p> fir1 fir1(N,Wn)N FIR fix fix(x)x </p><p> flipud flipud(X) X floor floor(x)x x </p><p> for for end </p><p> freqs freqs(b,a,w) b a</p><p> freqz freqz(b,a,w) </p><p> freqz2 freqz2(X)2 freqztrans freqztrans(b,a,ftype,thetac,wc)Symbolic Math Toolbox function </p><p> gray gray </p><p> grid grid: hamming hamming(N)Hamming N hanning hanning(N)Hanning N hold hold on </p><p> if </p><p> ifft ifft(x)x </p><p> imag imag(x) x </p><p> imnoise J=imnoise(I,TYPE,...) I </p><p> impinvar impinvar(B,A,Fs) B A </p><p>BZ,AZ </p><p> imread A=imread(FILENAME,FMT)FILENAME A </p><p> imresize imresize(A,s) A s </p><p> imshow imshow(I,[LOW HIGH]) I </p></li><li><p> 14</p><p> iztrans iztrans(f)Symbolic Math Toolbox f z kaiser kaiser(N,beta)beta Kaiser N </p><p> legend legend(string1,string2,string3, ...) figure </p><p> length length(x) x </p><p> linspace linspace(x1,x2,n)x1 x2 n </p><p> log10 log10(x)x 10 </p><p> log2 log2(x)x 2 </p><p> max max(x)x </p><p> mesh mesh(X,Y,Z) </p><p> meshgrid meshgrid(x,y) y( x) 2 x y</p><p> min min(x)x </p><p> mod mod(x,y)x y myconv myconv(h,x) h x </p><p> MATLAB conv mydft mydft(x) x </p><p> myfft myfft(x) x </p><p> myfilter myfilter(b,a,x)MATLAB filter numden numden(A)Symbolic Math Toolbox A</p><p> ones ones(m,n) 1 m n pcolor pcolor(X,Y,Z)3 plot plot(x,y)xy </p><p> plot(x,y,'o') </p><p> plot3 plot(x,y,z)3 poly2sym poly2sym(b,z)Symbolic Math Toolbox b</p><p> z </p><p> prod prod(X)XX </p><p> real real(x)x </p><p> roots roots(C) C </p><p> shading shading interp </p><p> simple simple(s)Symbolic Math Toolbox s simplify smplify(S)Symbolic Math Toolbox S </p><p> sin sin(x)x </p><p> sinc sinc(x)x sinc </p></li><li><p> 15</p><p> y = sin(pi*x)/(pi*x) x ~= 0 </p><p> = 1 x == 0 </p><p> size size(X) X </p><p> sqrt sqrt(x)x </p><p> stem stem(x,y)xy </p><p> subplot subplot(m,n,p):figure m n p </p><p> surfl surfl(X,Y,Z)3 switch case </p><p> sym2poly sym2poly(A)Symbolic Math Toolbox A </p><p> syms Symbolic Math Toolbox symsum symsum(s,a,b)Symbolic Math Toolbox s a b </p><p> tan tan(x)x </p><p> tf2sos tf2sos(B,A) AB 2 </p><p> unwrap unwrap(P) P2 view view(AZ,EL)3 AZEL</p><p> while while end </p><p> xlabel xlabel('text') x </p><p> ylabel ylabel('text') y </p><p> zeros zeros(m,n)m n </p><p> zlabel zlabel('text') z </p><p> zp2tf zp2tf(Z,P,K) Z P K</p><p> zplane zplane(Z,p) Z p</p><p> ztrans ztrans(f,k,w)Symbolic Math Toolbox k f z </p><p> MATLAB 2000 R. Vaillancourt MATLAB1997 MATLAB CG1995 MATLAB 1998 </p></li><li><p> 16</p><p>MathWorks https://jp.mathworks.com/ </p><p>OctaveMATLAB </p><p>Octave MATLAB MATLAB </p><p>Octave MATLAB </p><p> MATLAB toolbox </p><p> Octave </p><p>Octave </p><p> Octave http://www.mk.ecei.tohoku.ac.jp/dsptext/octave/ Octave (): http://www.gnu.org/software/octave/ </p><p>MATLAB Octave 2002 MATLAB CG1995 MATLAB 2001 Linux Tools for Numerical Computation on Linux </p></li></ul>

Recommended

View more >