《DSP using MATLAB》示例Example7.19

代码:

M = 33; alpha = (M-1)/2; Dw = 2*pi/M; l = 0:M-1; wl = Dw*l; 

%Hdr = [0, 0, 1, 1]; wdl = [0, 0.6, 0.8, 1];               % Ideal Amp Res for plotting
k1 = 0:floor((M-1)/2); k2 = floor((M-1)/2)+1:M-1;

Hrs = [j*Dw*k1, -j*Dw*(M-k2)];
angH = [-alpha*Dw*k1, alpha*Dw*(M-k2)]; 
H = Hrs.*exp(j*angH); h = real(ifft(H, M));

%[db, mag, pha, grd, w] = freqz_m(h, 1);
[Hr, ww, c, L] = Hr_Type3(h);

%Plot 
figure('NumberTitle', 'off', 'Name', 'Exameple 7.19')
set(gcf,'Color','white'); 

subplot(2,2,1); plot(wl(1:16)/pi, abs(Hrs(1:16))/pi, 'o', ww/pi, Hr/pi); axis([0, 1, -0.5, 1.5]); grid on;
xlabel('frequency in pi nuits'); ylabel('Hr(k) in pi units'); title('Differentiator, frequency sampleing design: M=33');

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

subplot(2,2,3); plot(w/pi, pha/pi); axis([0, 1, -1.5, 1.5]); grid on;
xlabel('frequency in pi units'); ylabel('pha(w)'); title('Phase Response');

subplot(2,2,4); plot(w/pi, db); axis([0, 1, -60, 10]); grid on;
xlabel('frequency in pi units'); ylabel('Decibels'); title('Magnitude Response');

  运行结果:

    从图看出,不是全频带(full-band)差分。

牢记: 1、如果你决定做某事,那就动手去做;不要受任何人、任何事的干扰。2、这个世界并不完美,但依然值得我们去为之奋斗。
原文地址:https://www.cnblogs.com/ky027wh-sx/p/6649461.html