# Combining two FIR band-pass filters

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?

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);

y2 = filter(b2, 1, filter(b1, 1, x));

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)))) • Although it is the right answer, And (signal-processing-wise) is the more correct way to do the filtering - I didn't mark you as answer because the answer I was looking for was how to combine the two outputs to produce the desired output. I would like to emphasize again that your answer is the most efficient way to solve this problem. – Henry Aloni Dec 10 '13 at 9:05
• Marked as answer. Thanks for the code example! – Henry Aloni Dec 17 '13 at 11:44

Just use the output of the first filter as input into the second

output1 = doFIRBandPassFilter(input,low1,high1);
output2 = doFIRBandPassFilter(output1,low2,high2);

• This is not very smart: low2 and high2 must be within the range (low1,high1), which means that the first filter is obsolete, no? – Henry Aloni Dec 9 '13 at 13:52
• Then please clarify the question. If you want to the band passes in cascade, my code snippet shows the correct way. If you want the band passes in parallel, just add the outputs. Neither case makes a lot of sense to me. If your application is different from cascade or parallel, then please describe it – Hilmar Dec 9 '13 at 19:11

I'm assuming that the two bandpass regions do not overlap. If that is the case you can combine the output of both by simply adding the two outputs together.