Filter designing using Kaiser window
19 views (last 30 days)
Show older comments
Hi! I'm just new to Matlab and still struggling to find a solution for my assignment. The task is to design a low pass, high pass, and band pass filers with the support of Kaiser window method. can somebody show me a possible way. Thanks!
0 Comments
Answers (1)
Star Strider
on 16 Dec 2016
Here is some example code for an Answer I posted a few days ago. Since this is a homework assignment, I will let your puzzle through it to understand how it works.
The Code:
Fs = 1E+4; % Sampling Frequency
Fn = Fs/2; % Nyquist Frequency
Wp = [0.1 0.5 100 110];
fsamp = Fs;
fcuts = Wp;
mags = [0 1 0];
devs = [0.05 0.01 0.05];
[n,Wn,beta,ftype] = kaiserord(fcuts,mags,devs,fsamp);
n = n + rem(n,2);
hh = fir1(n,Wn,ftype,kaiser(n+1,beta),'scale');
figure(1)
freqz(hh, 1, 2^nextpow2(length(hh)), Fs)
figure(2)
freqz(hh, 1, 2^nextpow2(length(hh)), Fs)
set(subplot(2,1,1), 'XLim', [0 150]) % Zoom Frequency-Axis
set(subplot(2,1,2), 'XLim', [0 150]) % Zoom Frequency-Axis
figure(3)
freqz(hh, 1, 2^nextpow2(length(hh)), Fs)
set(subplot(2,1,1), 'XLim', [0 10]) % Zoom Frequency-Axis
set(subplot(2,1,2), 'XLim', [0 10]) % Zoom Frequency-Axis
It is a bandpass filter for EKG filtering, with a passband of 0.5 Hz to 100 Hz. See the documentation for the relevant functions for details on how to use them.
2 Comments
Helia
on 17 Nov 2023
Hi, could you explain why you used "n = n + rem(n, 2)"? I couldn't figure out the reason.
Thanks
Star Strider
on 17 Nov 2023
My pleasure.
See what it actually does —
for n = 9:12
n
n = n + rem(n,2)
disp(' ')
end
It calculates the order ‘n’ so that it will always be even.
.
See Also
Categories
Find more on Kaiser in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!