matlab實驗指導解讀 - 下載本文

n1 = 0:length(num1)-1; n2 = 0:length(num2)-1; subplot(2,2,1); stem(n1,num1);

xlabel('Time index n');ylabel('Amplitude'); grid; title('Type 1 FIR Filter'); subplot(2,2,2); stem(n2,num2);

xlabel('Time index n');ylabel('Amplitude'); grid; title('Type 2 FIR Filter'); subplot(2,2,3); stem(n1,num3);

xlabel('Time index n');ylabel('Amplitude'); grid; title('Type 3 FIR Filter'); subplot(2,2,4); stem(n2,num4);

xlabel('Time index n');ylabel('Amplitude'); grid; title('Type 4 FIR Filter'); pause

subplot(2,2,1); zplane(num1,1); title('Type 1 FIR Filter'); subplot(2,2,2); zplane(num2,1); title('Type 2 FIR Filter'); subplot(2,2,3); zplane(num3,1); title('Type 3 FIR Filter'); subplot(2,2,4); zplane(num4,1); title('Type 4 FIR Filter');

disp('Zeros of Type 1 FIR Filter are'); disp(roots(num1));

disp('Zeros of Type 2 FIR Filter are'); disp(roots(num2));

disp('Zeros of Type 3 FIR Filter are'); disp(roots(num3));

disp('Zeros of Type 4 FIR Filter are'); disp(roots(num4));

4. 用MATLAB產生序列的圓周移位,并畫圖觀察該現象, clf;

x = [0 2 4 6 8 10 12 14 16]; N = length(x)-1; n = 0:N; y = circshift(x,5); XF = fft(x); YF = fft(y); subplot(2,2,1)

stem(n,abs(XF));grid

title('Magnitude of DFT of Original Sequence');

subplot(2,2,2)

stem(n,abs(YF));grid

title('Magnitude of DFT of Circularly Shifted Sequence'); subplot(2,2,3)

stem(n,angle(XF));grid

title('Phase of DFT of Original Sequence'); subplot(2,2,4)

stem(n,angle(YF));grid

title('Phase of DFT of Circularly Shifted Sequence');

5、用MATLAB編寫快速傅里葉變換,并實現偶序列的DFT的虛實部,采用圖形表示。 % Program P3_11

% Relations between the DFTs of the Periodic Even % and Odd Parts of a Real Sequence

x = [1 2 4 2 6 32 6 4 2 zeros(1,247)]; x1 = [x(1) x(256:-1:2)]; xe = 0.5 *(x + x1); XF = fft(x); XEF = fft(xe); clf;

k = 0:255;

subplot(2,2,1);

plot(k/128,real(XF)); grid; ylabel('Amplitude');

title('Re(DFT\\{x[n]\\})'); subplot(2,2,2);

plot(k/128,imag(XF)); grid; ylabel('Amplitude');

title('Im(DFT\\{x[n]\\})'); subplot(2,2,3);

plot(k/128,real(XEF)); grid;

xlabel('Time index n');ylabel('Amplitude'); title('Re(DFT\\{x_{e}[n]\\})'); subplot(2,2,4);

plot(k/128,imag(XEF)); grid;

xlabel('Time index n');ylabel('Amplitude'); title('Im(DFT\\{x_{e}[n]\\})');

6、編寫穩定性測試程序 % Program P4_4 % Stability Test clf;

den = input('Denominator coefficients = '); ki = poly2rc(den);

disp('Stability test parameters are');

disp(ki);

7、用MATLABD 編寫基于FFT的帕斯瓦爾定理。 % Program P3_12

% Parseval's Relation

x = [(1:128) (128:-1:1)]; XF = fft(x); a = sum(x.*x)

b = round(sum(abs(XF).^2)/256)

四、本實驗用到的matlab命令

filter Freqz impz filrfilt residuez

tf2zp zp2sos zplane fft sinc zplane 實驗四:IIR&FIR數字濾波器的設計

一、 實驗目的:

1、熟悉無限沖激響應(IIR)和有限沖激響應(FIR)網絡結構,對比學習模擬濾波器和數字濾波器的常用指標; 2、熟悉沖激響應不變法和雙線性變換法設計低通濾波器的程序編寫,并深化理解; 3、熟悉FIR線性相位濾波器的概念及其表示; 4、熟悉FIR濾波器窗函數設計法;

5、熟悉兩種濾波器設計過程,并可修改其設計指標,對比輸出效果。

二、實驗內容:

1、IIR(無限沖激響應濾波器)階數估計及其buttworth和chybyshev濾波器設計; 2、沖激響應不變法和雙線性變換法設計;

3、FIR濾波器設計中出現頻域出現吉布斯現象的來由; 3、有限沖激響應濾波器窗函數設計法;

三、實驗計算及例程

1、設低通DF的3dB帶寬頻率wc=0.2π,止帶頻率ws=0.4π,在 w=ws處的止帶衰減20lg|H(ejws)|=-15dB,試用脈沖響應不變法(沖激不變法)設計一個Butterworth低通DF。(設采樣頻率fs=20kHz)

Wp=input('Normalized passband edge =');

Ws=input('Normalized stopband edge ='); Rp=input('Passband ripple in dB =');

Rs=input('Minimum stopband attenuation in dB ='); [N,Wn]=buttord (Wp,Ws,Rp,Rs); [b,a]=butter(N,W n);

[h,omega]=freqz(b,a,512);

plot(omega/pi,20*log10(abs(h))); grid;

xlabel('\\omega/\\pi'); ylabel('Gain dB');

title('IIR Butterworth Lowpass Filter');

2無限沖激響應濾波器階數估計和濾波器設計 巴特沃茲帶阻濾波器

Ws = [0.4 0.6]; Wp = [0.2 0.8]; Rp = 0.4; Rs = 50; % Estimate the Filter Order

[N1, Wn1] = buttord(Wp, Ws, Rp, Rs); % Design the Filter

[num,den] = butter(N1,Wn1,'stop'); % Display the transfer function

disp('Numerator Coefficients are ');disp(num); disp('Denominator Coefficients are ');disp(den); % Compute the gain response [g, w] = gain(num,den); % Plot the gain response plot(w/pi,g);grid axis([0 1 -60 5]);

xlabel('\\omega /\\pi'); ylabel('Gain in dB');

title('Gain Response of a Butterworth Bandstop Filter')

3、吉布斯環的生成;

在FIR窗函數設計法中,頻域傅立葉變換的無限振蕩諧波數列疊加合成時,會產生尖銳不連續的區間,好比方波的下降及上升,這就是吉布斯現象,這種現象產生的不僅與諧波的疊加合成的數量有關,而且其變化的寬度隨合成的個數增加而變窄。

單位方波: 傅立葉級數表示:

function y = gibbs(x,M,duty)

% GIBBS

% x: 待估價的值 (0

if (nargin<3) duty = 0.5; end p = (-M:M); for (j=1:length(x))

y(j) = sum(duty*sinc(duty*p).*exp(-i*2*pi*p*abs(x(j)))); end





海南麻将怎么玩图解 股票权重怎么看 网络炒股平台 上证指数上证指数 集中盈炒股平台正规 杠杆炒股有哪些推荐 如何看懂股票k线图 炒股网上交易平台 股票底部放量下跌 杠杆炒股的app合法吗 天顺股份股票