Implementation of filter bank using fir1
3 次查看(过去 30 天)
显示 更早的评论
I'm trying to implement a filter bank using fir1 and a kaiser filter.
I have currently implemented my fir1 filter for the lowest frequency band
lpf = fir1(L-1,500/4000,kaiser(L,3));
and now need to shift this filter up to create a total of 10 bands at 250Hz intervals.
How can I shift up the bandpass filter? I would be looking to use some kind of for loop e.g. to apply some function to lpf in order to shift it up by the desired frequency?
0 个评论
采纳的回答
Paul
2022-1-22
Take advantage of the frequency shift property of the DTFT.
For example
Fs = 1000;
f = (-0.5:.001:0.5)*Fs;
L = 50;
lpf = fir1(L-1,500/4000,kaiser(L,3));
h0 = freqz(lpf,1,f,Fs);
h250 = freqz(lpf.*exp(1j*250/Fs*2*pi*(0:(numel(lpf)-1))),1,f,1000);
figure
plot(f,abs([h0(:) h250(:)])),grid
xline(250)
xlabel('Frequency (Hz)');
ylabel('Magnitude')
This approach does result in the shifted filter having complex coefficients, which might not be what you want. If it's not what you want, the problem might have to be reformulated.
6 个评论
Paul
2022-1-23
As to the second question, it looks like the filter design parameters changed. As shown, lpf from the original code was low pass and from the new code is bandpass.
Fs = 8000;
f = (-0.5:.001:0.5)*Fs;
L = 50;
lpf = fir1(L-1,500/4000,kaiser(L,3)); % lpf in the original question
fcuts = [1000 1300 2210 2410];
mags = [0 1 0];
devs = [0.01 0.05 0.01];
fsamp = Fs;
[n,Wn,beta,ftype] = kaiserord(fcuts,mags,devs,fsamp);
n = n + rem(n,2);
lpfnew = fir1(n,Wn,ftype,kaiser(n+1,beta),'noscale'); % lpf from comment above
[h0,f0] = freqz(lpf,1,1024,Fs);
[hnew,fnew] = freqz(lpfnew,1,1024,Fs);
figure
plot([f0 fnew],abs([h0 hnew])),grid
legend('lpf','lpfnew')
As to the first question, maybe you could achieve your goal by designing 10 different filters and adding them together (rather than shifted copies of a single filter) to get the desired, overall frequency response.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Digital Filter Design 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!