www.gusucode.com > dsp 案例源码程序 matlab代码 > dsp/InverseDirichletSincShapedPassbandExample.m
%% Inverse-Dirichlet-Sinc-Shaped Passband % Design two order 30 constrained equiripple FIR filters with % inverse-Dirichlet-sinc-shaped passbands. The cutoff frequency in both % designs is pi/4 radians/sample. % Set |C=1| in one design |C=2| in the second design. The maximum passband % and stopband ripple is 0.05. Set |p=1| in one design and |p=2| in the % second design. %% % Design the filters. % b1 = firceqrip(30,0.25,[0.05 0.05],'invdiric',[1 1]); b2 = firceqrip(30,0.25,[0.05 0.05],'invdiric',[2 2]); %% % Obtain the filter frequency responses using |freqz|. Plot the magnitude % responses. % [h1,~] = freqz(b1,1); [h2,w] = freqz(b2,1); plot(w,abs(h1)); hold on; plot(w,abs(h2),'r'); axis([0 pi 0 1.5]); xlabel('Radians/sample'); ylabel('Magnitude'); legend('C=1 p=1','C=2 p=2'); %% % Inspect the stopband ripple in the design with |C=1| and |p=1|. The constrained % design sets the maximum ripple to be 0.05. Zoom in on the stopband from % the cutoff frequency of pi/4 radians/sample to 3pi/4 radians/sample. % figure; plot(w,abs(h1)); set(gca,'xlim',[pi/4 3*pi/4]); grid on;