Design a low pass filter using kaiser window

15 views (last 30 days)
I need to setup a FIR filter for a signal with pass band cutoff 3.2 Hz, stop band cutoff 4.8 Hz, pass band ripple 0.1 dB, stop band attenuation 44 dB and sample frequency 16 Hz
After reading the documentation I tried this. Is the implementation correct?
[n,Wn,beta,ftype] = kaiserord([3.2 4.8],[1 0],...
[0.1 44],16);
b = fir1(n,Wn,ftype,kaiser(n+1,beta),'noscale');
c = kaiserord([3.2 4.8],[1 0],[0.1 44],16,'cell');
bcell = fir1(c{:});
hfvt = fvtool(b,1,bcell,1);
legend(hfvt,'b','bcell');

Accepted Answer

John BG
John BG on 18 Dec 2016
Like Start Strider points out you can manually key in filter parameter in the fvtool GUI, but can also key in all fvtool parameters in a single MATLAB line:
LpFilt = designfilt('lowpassfir', ...
'PassbandFrequency',0.2, ...
'StopbandFrequency',30, ...
'PassbandRipple',0.1, ...
'StopbandAttenuation',44, ...
'SampleRate',100, ...
'DesignMethod','kaiserwin');
figure(1);fvtool(LpFilt)
the following filters test noise through this LPF .
dataIn = rand(1000,1);
dataOut = filter(LpFilt,dataIn);
subplot(2,1,1);plot(dataIn);title('input noise')
subplot(2,1,2);plot(dataOut);title('LPF Kai filtered noise')
.
would it be possible to let us the readers know what book are these exercises from?
.
if you find these lines useful would you please mark my answer as Accepted Answer?
To any other reader, please if you find this answer of any help, please click on the thumbs-up vote link,
thanks in advance for time and attention
John BG

More Answers (1)

Star Strider
Star Strider on 16 Dec 2016
For what it’s worth, it seems to me to do what you designed it to do. In the fvtool GUI, you need to open the ‘Analysis’ tab and enter your sampling frequency (the last item in the drop-down menu) to verify the frequencies of the passband and stopband.
  2 Comments
Gehan Kavinda
Gehan Kavinda on 16 Dec 2016
Edited: Gehan Kavinda on 16 Dec 2016
This was my problem which was taken from Digital Signal Processing by Andreas Antoniou.(Pg No:462)
Star Strider
Star Strider on 16 Dec 2016
The frequencies you calculated from the radian frequencies are approximately correct (you rounded them to the nearest 0.1). By that criterion, the filter is correct. I don’t recognise the notation of ‘Ap’ and ‘Aa’, so I assume you interpreted them correctly. (I can’t find my copy of Antoniou just now.) Your filter has about 40 dB stopband ripple and about 20 dB stopband attenuation. I didn’t specifically measure the passband ripple, but it looks correct.

Sign in to comment.

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!