www.gusucode.com > dsp 案例源码程序 matlab代码 > dsp/DesignOfLowpassFilterExample.m
%% Design of Lowpass Filter % This example requires the DSP System Toolbox product. % % Design a lowpass filter to be used on a signal sampled at 96 kHz. The passband % of the filter extends up to 20 kHz. The stopband of the filter starts at 24 % kHz. Specify a passband ripple of 0.01 dB and a stopband attenuation of 80 dB. % Determine automatically the order required to meet the specifications. % % Set up the filter design specifications and determine the available design % algorithms. % Copyright 2015 The MathWorks, Inc. Fs = 96e3; Fpass = 20e3; Fstop = 24e3; Apass = 0.01; Astop = 80; filtSpecs = fdesign.lowpass(Fpass,Fstop,Apass,Astop,Fs); designmethods(filtSpecs) %% % Design an equiripple FIR filter and an elliptic IIR filter that meet the % specifications. Measure the designs to verify that the filters satisfy the constraints. lpFIR = design(filtSpecs,'equiripple','SystemObject',true); lpIIR = design(filtSpecs,'ellip','SystemObject',true); FIRmeas = measure(lpFIR) IIRmeas = measure(lpIIR) %% % Estimate and display the computational cost of each filter. The equiripple % FIR filter requires many more coefficients than the elliptic IIR filter. FIRcost = cost(lpFIR) IIRcost = cost(lpIIR) %% % Visualize the resulting designs with FVTool to compare their properties. fvtool(lpFIR,lpIIR,'Fs',Fs); legend('FIR Equiripple','Elliptic IIR')