Here are the specs for FIR filter using Kaiser window.

Ap = 0.2   %Maximum Passband ripple
Aa = 20    %Minimum stopband attenuation
Wp1 = 500  %Lower passband edge
Wp2 = 1000 %Upper passband edge
Wa1 = 200  %Lower stopband edge
Wa2 = 1200 %Upper stopband edge
Ws = 3200  %Sampling frequency

I used two methods. designfilt function and kaiserord with fir

Code using designfilt

Ap = 0.2;   %Maximum Passband ripple
Aa = 20;    %Minimum stopband attenuation
Wp1 = 500;  %Lower passband edge
Wp2 = 1000; %Upper passband edge
Wa1 = 200;  %Lower stopband edge
Wa2 = 1200; %Upper stopband edge
Ws = 3200;  %Sampling frequency

fp1 = Wp1/(2*pi);
fp2 = Wp2/(2*pi);
fa1 = Wa1/(2*pi);
fa2 = Wa2/(2*pi);
fs = Ws/(2*pi);

bpFilt = designfilt('bandpassfir','PassbandFrequency1',fp1, ...
    'PassbandFrequency2',fp2, 'StopbandFrequency1',fa1, ...
    'StopbandFrequency2',fa2, 'SampleRate',fs, ...
    'PassbandRipple',Ap,'StopbandAttenuation1',Aa, 'StopbandAttenuation2',Aa,...
h = fvtool(bpFilt);

filtord(bpFilt) %Order of the filter

Code using kaiserord with fir

fcuts = [fa1 fp1 fp2 fa2];  %Band edges
mags = [0 1 0];     %Desired amplitudes on bands defined by fcuts

deltaP = (10^(0.05*Ap)-1)/(10^(0.05*Ap)+1); %Passband ripple
deltaA = 10^(-0.05*Aa);  %Stopband ripple

errors = [deltaA deltaP deltaA];    %maximum allowable error in each frequency band

%Order n, frequency vector Wn, multiband magnitude type ftype, and the Kaiser window parameter beta
[n,Wn,beta,ftype] = kaiserord(fcuts,mags,errors,fs);

bpFilt = fir1(n,Wn,ftype,kaiser(n+1,beta),'noscale');   %length of window = filter order + 1

Problem is that coefficients in bpFiltfrom 2nd method are not the same as bin 1st.

Refer following: 1st method coefficients

2nd method coefficients

Why is that happening?

  • 2
    $\begingroup$ and how do they differ? Are the filter orders the same? Can you add a plot with both of them? $\endgroup$ Jun 5, 2017 at 16:56
  • $\begingroup$ @MarcusMüller Yes. For filter order I get 35. But transfer function coefficients are not the same. $\endgroup$
    – Sndn
    Jun 6, 2017 at 8:08
  • $\begingroup$ to repeat myself: 1. and how do they differ? as well as 2. Can you add a plot with both of them? $\endgroup$ Jun 6, 2017 at 8:47
  • $\begingroup$ @MarcusMüller Coefficient values are different. Check the two images. $\endgroup$
    – Sndn
    Jun 10, 2017 at 5:57
  • $\begingroup$ .... oh, really. How do they differ? Are they scaled? Where's the plot I'm asking for thrice? $\endgroup$ Jun 10, 2017 at 6:50


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.