Introduction to Matlab VLSI Signal Processing Lab NCTU
Introduction to Matlab 吳家揚 VLSI Signal Processing Lab, NCTU 3/1, 2014 *source: “張智星, Matlab 程式設計與應用, 清蔚科技出版”
Outline n n n Introduction Basic operations Graphics Filter design On-line resources
Environment n n Command window Workspace window Current directory Command history
Outline n n n Introduction Basic operations Graphics Filter design On-line resources
Outline n n n Introduction Basic operations Graphics Filter design On-line resources
Plot n Data q q n >> x = 0 : 0. 1 : 2*pi; >> y = sin(x); PLOT q plot(y) % x = 0, 0. 1, 0. 2, . . . , 6. 2
Plot n plot(x, y) q 指定x軸的數值
Multi-Data Plot n Method I: q n n n plot(x 1, y 1, x 2, y 2, . . . ) e. g. >> y = sin(x); >> z = sin(x + pi/4); >> plot(x, y, x, z); Method II: q q q >> plot(x, y, ‘b’); >> hold; % 維持目前輸出 圖形不變 >> plot(x, z, ‘g’);
圖形標示 n n title(‘title: sine wave’) xlabel(‘水平軸’) ylabel(‘垂直軸’) axis([xmin xmax ymin ymax])
Outline n n n Introduction Environment Basic operations Graphics Filter design On-line resources
Filter Representation in Matlab n Digital filter representation q q q n B(ejw) b(1) + b(2)e-jw +. . + b(m+1)e-jmw H(ejw) = -------------------------A(ejw) a(1) + a(2)e-jw +. . + a(n+1)e-jnw A filter is specified by the two vector a and b
Filter Response Analysis n [H, W] = freqz(b, a, N) q n returns the N-point complex frequency response vector H and the N-point frequency vector W in radians/sample of the filter Use plot command to plot the frequency response q q Plot( w/pi, db(abs(H)) ) Axis([0 1 -150 10])
Filter Response Analysis (cont’d) n freqz(B, A, . . . ) with no output arguments plots the response
FDATool n Type fdatool in the command window q q Choose filter type Set constraints Design filter File > export
Example 2. 1 n n n n A=1; n_max = 11; n = -n_max: 1: n_max; X = zeros(size(n)); I = find(n==1); II = find (n==-1); III = find(mod(n, 2)==0); X(I) = -j*A/4; X(II) = j*A/4; X(III) = A. /(pi*(1. -n(III). ^2)); [arg_X, mag_X] = cart 2 pol(real(X), imag(X)); stem(n, mag_X); stem(n, arg_X);
On-line Resources n MATLAB 程式設計與應用(網路版), 張智星 q n MATLAB程式設計入門篇, 張智星 q n http: //mirlab. org/jang/books/matlab. Programming 4 beginner/slide/ Matlab線上教材 q n http: //www. cs. nthu. edu. tw/~jang/mlbook/ http: //libai. math. ncu. edu. tw/bcc 16/B/matlab/ Matlab 簡介, 馮丁樹 q http: //ecaaser 5. ecaa. ntu. edu. tw/weifang/matlab/index-matlab. htm
- Slides: 30