《DSP using MATLAB》示例Example7.12

代码:

M = 21; alpha = (M-1)/2; n = [0:1:M-1]; 

hd = (cos(pi*(n-alpha)))./(n-alpha); hd(alpha+1) = 0;

w_ham = (hamming(M))'; 

h = hd .* w_ham;
[Hr, w, c, L] = Hr_Type3(h);  

%Plot

figure('NumberTitle', 'off', 'Name', 'Exameple 7.12')
set(gcf,'Color','white'); 

subplot(2,2,1); stem(n, hd); axis([-1 M -1.2 1.2]); grid on;
xlabel('n'); ylabel('hd(n)'); title('Ideal Impulse Response');

subplot(2,2,2); stem(n, w_ham); axis([-1 M 0 1.2]); grid on;
xlabel('n'); ylabel('w(n)'); title('Hamming Window');

subplot(2,2,3); stem(n, h); axis([-1 M -1.2 1.2]); grid on;
xlabel('n'); ylabel('h(n)'); title('Actual Impulse Response');

subplot(2,2,4); plot(w/pi, Hr/pi); axis([0 1 0 1]); grid on;
xlabel('frequency in pi units'); ylabel('slope in pi units'); title('Amplitude Response');

  运行结果:

posted @ 2017-03-28 07:39  跑啊跑  阅读(185)  评论(0)    收藏  举报