www.gusucode.com > dsp 案例源码程序 matlab代码 > dsp/DesignanAntisymmetricFilterwithPiecewiseLinearPassbandsExample.m

    %% Design an Antisymmetric Filter with Piecewise Linear Passbands  
% The following shows how to design a 24th-order anti-symmetric filter with
% piecewise linear passbands, and plot the desired and actual amplitude
% responses.   

%% 
% Create the frequency and amplitude vectors, |f| and |a|. 
f = [0 0.3 0.4 0.6 0.7 0.9];
a = [0 1 0 0 0.5 0.5];  

%% 
% Use |firls| to obtain the 25 coefficients of the filter. 
b = firls(24,f,a,'hilbert');  

%% 
% Plot the ideal amplitude response along with the transition regions. 
plot(f.*pi,a,'o','markerfacecolor',[1 0 0]);
hold on;
plot(f.*pi,a,'r--','linewidth',2);  

%% 
% Use |freqz| to obtain the frequency response of the designed filter and
% plot the magnitude response of the filter. 
[H,F] = freqz(b,1);
plot(F,abs(H));
set(gca,'xlim',[0 pi])
legend('Filter Specification','Transition Regions','Magnitude Response')