Actually, you can use that very same function butter()
to design bandpass filters as well, simply by supplying a vector of cutoff frequencies instead of a scalar:
% filter design
fs = 100;
f1 = 15;
f2 = 20;
% normalized frequency
w1 = f1 / (fs/2);
w2 = f2 / (fs/2);
% second-order butterworth
[b, a] = butter(2, [w1 w2]);
% filtering
x = randn(1, 10000);
y = filter(b, a, x);
In your question, you're talking about the need for an FIR filter. However, a Butterworth filter has an infinite impulse response, as you can see from the fact that the function butter()
returns a vector a
with more than one element.