www.gusucode.com > signal 案例源码程序 matlab代码 > signal/PhaseResponseOfAnFIRFilterExample.m
%% Phase Response of an FIR Filter % Use |designfilt| to design an FIR filter of order 54, normalized cutoff % frequency $0.3\pi$ rad/s, passband ripple 0.7 dB, and stopband % attenuation 42 dB. Use the method of constrained least squares. Display % the phase response of the filter. % Copyright 2015 The MathWorks, Inc. %% Nf = 54; Fc = 0.3; Ap = 0.7; As = 42; d = designfilt('lowpassfir','CutoffFrequency',Fc,'FilterOrder',Nf, ... 'PassbandRipple',Ap,'StopbandAttenuation',As, ... 'DesignMethod','cls'); phasez(d) %% % Design the same filter using |fircls1|. Keep in mind that |fircls1| uses % linear units to measure the ripple and attenuation. pAp = 10^(Ap/40); Apl = (pAp-1)/(pAp+1); pAs = 10^(As/20); Asl = 1/pAs; b = fircls1(Nf,Fc,Apl,Asl); phasez(b)