Simple butter filtering question!

Started by April 1, 2008
Hello everyone,

I was wondering if anyone could give me their insight to this problem.
I am trying to understand how to use a bandpass filter in butter to pass only a certain band of frequency.

This works for a simple cosine with one frequency, but with a summation of cosines..

dt=.001; %sampling rate
Fs=1/dt; %sampling freq
[b,a]=butter(4,[48 51]/HalfFs);
subplot(121),plot(t,m),title('original message'),axis([-.1,.6,-5,5])
subplot(122),plot(t,y),title('filtered message'),axis([-.1,.6,-5,5])

The output signal should be the same, right? Or is this due to some sort of transient response? It looks like just a change in delay. Any insight would be much appreciated. Thanks!

your code is just fine.
Try plotting the two signals in a larger time window, for example
[-1 1] and not [-0.1 0.6] and you will see that the initial signal has undergone just a delay.