MATLAB: Fir and iir filtering

fir and iir filtering

can any one give me the code for fir and iir lowpass and highpass filters of a given input sequence. regards k.v.swamy

Best Answer

You have to know your filter specifications. If you do, you can do both with fdesign.lowpass and fdesign.highpass
fdesign.lowpass and fdesign.highpass have different specification strings which support different filter designs.
The default string 'Fp,Fst,Ap,Ast' supports both FIR and IIR designs.
Here is an example:
Design a lowpass filter with a passband frequency of 1 kHz, a stopband frequency of 1.5 kHz, passband ripple of 0.5 dB, and stopband attenuation of 40 dB. The sampling frequency is 20 kHz
d = fdesign.lowpass('Fp,Fst,Ap,Ast',1e3,1.5e3,0.5,40,20e3);
designmethods(d) %shows which designs are valid for this spec
Hdeq = design(d,'equiripple'); % FIR filter
Hbutt = design(d,'butter'); %IIR design