Hi Gehan
there are different ways to build a HPF with Kaiser time windowing
1.- manually building the time window for a LPF
wp=0.2*pi;ws=.3*pi;As=45;Ap=.3
tr_width=ws-wp;
M=ceil((As-7.95)/(2.285*tr_width)+1)+1
if As>=50
beta=0.1102*(As-8.7)
end
if As<50 && As>=21
beta=0.582*(As-21)^.4+.07886*(As-21)
end
n=[0:1:M-1]
wc=(ws+wp)/2;hd=ideal_lp(wc,M);
w_kai=(kaiser(M,beta))';h=hd.*w_kai;
[db,mag,pha,grd,w]=freqz_m(h,[1]);
delta_w=2*pi/1000;
subplot(2,2,1);stem(n,hd);title('ideal impulse response')
axis([0 M-1 -0.1 .3]);xlabel('n');ylabel('hd(n)')
subplot(2,2,2);stem(n,w_kai);title('Kaiser time window')
axis([0 M-1 0 1.1]);xlabel('n');ylabel('w(n)')
subplot(2,2,3);stem(n,h);title('actual impulse response')
axis([0 M-1 -.1 .3]);xlabel('n');ylabel('h(n)')
subplot(2,2,4);plot(w/pi,db);title('|HkaiLPF| dB');grid
axis([0 1 -100 10]);xlabel('frequency in pi units');ylabel('dB')
and then applying the frequency translation
That luckily I am not doing here because oh wonder MATLAB has a single command to do it all:
HpFilt = designfilt('highpassfir','PassbandFrequency',0.3, ...
'StopbandFrequency',0.2,'PassbandRipple',0.5, ...
'StopbandAttenuation',45,'DesignMethod','kaiserwin');
figure(2);fvtool(HpFilt)
dataIn = rand(1000,1);
figure; subplot(2,1,1);plot(dataIn);title('input noise')
subplot(2,1,2);plot(dataOut);title('HPF Kai filtered noise')
the LPF obtained by 'mirroring' the HPF around the transition band would be
LpFilt = designfilt('lowpassfir','PassbandFrequency',0.2, ...
'StopbandFrequency',0.3,'PassbandRipple',0.5, ...
'StopbandAttenuation',45,'DesignMethod','kaiserwin');
figure(1);fvtool(LpFilt)
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')
Gehan
if you find this answer useful would you please be so kind to 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
John BG