Question

let say that we have signal with sampling frequency 100 hertz,i want to design FIR filter so that cut all frequency that are outsize of frequency range 15-20,if we convert it to the normalized frequency we will get 15/50=0.3 and 0.4,i know that for example i can use butter to design filter,for example like there http://www.emba.uvm.edu/~gmirchan/classes/EE275/Lab5.pdf

but could you help me please to design bandpass filter in matlab?let say we have some signal s(t),

this command

[b a] = butter(2, 400/(fs/2));

designs a second order Butterworth filter with cutoff frequency 400 and then this command

y = filter(b,a,swn);

filters given signal, but instead of one cut-off frequency, I need range 15-20, so how can I apply bandpass filter?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top