I am using IPP for FIR filtering over 1D data. I want to use the same input and filter it using two band pass filters. This is how I do it:
output1 = doFIRBandPassFilter(input,low1,high1);
output2 = doFIRBandPassFilter(input,low2,high2);
I want to combine those outputs so that the end result will show BOTH (low1,high1) and (low2,high2) filtered data.
If output1 and output2 are arrays - should I add them? multiply them? convolve them?
Answer
As you've indicated there may be some mismatching in the filter bands resulting in undesirable results. If one of the filters is heavily attenuating the frequencies of the other filter, there's little you can do to reconcile this by just cascading the filters together.
Given you'd like to maintain the response of both filters independent of the other, you need to add the filter outputs together.
Here's some code that shows the result of one filter heavily attenuating the frequencies of the other. It also shows the equivalence of cascading two filters either by connecting the output to the input of the next stage or just convolving the filter taps.
b1 = fir2(2048, [0 0.1 0.15 0.3 0.35 1], [0 0 1 1 0 0]);
b2 = fir2(128, [0 0.4 0.45 0.6 0.65 1], [0 0 1 1 0 0]);
x = randn(1, 32768);
% Parallel sum
y1 = filter(b1, 1, x) + filter(b2, 1, x);
% Cascade
y2 = filter(b2, 1, filter(b1, 1, x));
% Equivalent cascade
y3 = filter(conv(b1, b2), 1, x);
figure, hold all
subplot(311), plot(20*log10(abs(fft(y1))))
subplot(312), plot(20*log10(abs(fft(y2))))
subplot(313), plot(20*log10(abs(fft(y3))))
No comments:
Post a Comment