MATLAB: Filter Question – FIR and IRR

dspfiltersfiriir

Hey everyone, I'm trying to do the following:
Make an IIR and FIR filter that passes between 40-50 KHz, and blocks out noise that is occurring at 75Khz. There is 25 dB of stopband attenuation, and the passband ripple is set at 3.
With that noted, here is the code I have so far:
f_p=40000; %Pass Frequency in Hz
f_s=50000; %Stop Frequency in Hz
r_s=25; %Stopband Attenuation in dB
r_p=3; %Passband Ripple
d = fdesign.bandpass('Fst1,Fp1,Fp2,Fst2,Ast1,Ap,Ast2',38e3,f_p,f_s,53e3,r_s,r_p,140e3);
%Fst1 — frequency at the edge of the end of the first stop band. Specified in normalized frequency units by default.
%Fp1 — frequency at the edge of the start of the pass band. Specified in normalized frequency units by default.
%Fp2 — frequency at the edge of the end of the pass band. Specified in normalized frequency units by default.
%Fst2 — frequency at the edge of the start of the second stop band. Specified in normalized frequency units by default.
%Ap — passband ripple in dB (the default units).
%Ast1 — attenuation in the first stopband in dB (the default units).
%Ast2 — attenuation in the second stopband in dB (the default units).
% Create the FIR filter
Hd2 = design(d,'equiripple');
fvtool(Hd2)
%Create the IIR filter
Hd1 = design(d,'butter');
fvtool(Hd1);
——————————————————————
First off, does my methodology seem correct for creating an FIR and IIR filter that will accomplish this goal? Secondly, when I run the code, this is the error message I get:
??? Error using ==> fdesign.abstracttype.equiripple at 13
Frequency specifications must be between 0 and 1.
Error in ==> fdesign.abstracttype.superdesign at 106
Hd = feval(method, this, varargin{:});
Error in ==> fdesign.abstracttype.design at 11
varargout{1} = superdesign(this, varargin{:});
Error in ==> PEPractice at 13
Hd2 = design(d,'equiripple');
—————————————————————–
Any insight as to what is wrong? Please help if you can!

Best Answer

You have to use a supported specificaton string. If you want to limit the order to a fixed value, then you have to realize, you may not be able to specify other things. In a minimum-order design, you are allowing the filter design method to find the order, if you specify it, then you have to give up certain things.
d = fdesign.lowpass('N,Fp,Ap,Ast',4,50e3,3,25,200e3);
Hde = design(d,'ellip');
The above gets you more than 25 dB of stopband attenuation by 75 kHz.
But you may like:
Hd = design(d,'equiripple');
better.