Home > Archive > Matlab > September 2006 > Butterworth filter
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Butterworth filter
|
|
|
| My problem:
I have a signal, sampled at 2500 Hz. I need to highpass filter this
signal from 30Hz up.
my commands:
[b,a] = butter(order,30/1250,'high');
signalnew= filtfilt(b,a,signal);
Now if i compare the FFTs of my squared original and filtered
signals, this operation removes the power up to 300 hz.
What am I doing wrong/not understanding?
| |
| Rune Allnor 2006-09-29, 8:06 am |
|
GJB skrev:
> My problem:
>
> I have a signal, sampled at 2500 Hz. I need to highpass filter this
> signal from 30Hz up.
>
> my commands:
>
> [b,a] = butter(order,30/1250,'high');
> signalnew= filtfilt(b,a,signal);
>
> Now if i compare the FFTs of my squared original and filtered
> signals, this operation removes the power up to 300 hz.
>
> What am I doing wrong/not understanding?
What's the order of the filter? How do you determine it?
Could you post the coefficients a and b?
Rune
| |
|
| Rune Allnor wrote:
>
>
>
> GJB skrev:
> this
>
> What's the order of the filter? How do you determine it?
> Could you post the coefficients a and b?
>
> Rune
>
>
I was actually playing around to see what order to take. For the
fourth order case:
b =
0.90615955377025 -3.62463821508099 5.43695732262148
-3.62463821508099 0.90615955377025
a =
1.00000000000000 -3.80299754165439 5.42816596368390
-3.44626421809321 0.82112513689246
But the problem remains with higher and lower orders alike.
| |
| Rune Allnor 2006-09-29, 8:06 am |
|
GJB skrev:
> Rune Allnor wrote:
>
> I was actually playing around to see what order to take.
What is the allowed passband ripple? What is the required stop
band attenuation? What are the corner frequencies?
Rune
| |
|
| Rune Allnor wrote:
>
>
>
> GJB skrev:
highpass filter[color=darkred]
filtered[color=darkred]
hz.[color=darkred]
>
> What is the allowed passband ripple? What is the required stop
> band attenuation? What are the corner frequencies?
>
> Rune
>
>
Stop band attenuation: 50dB
corner frequencies: 10 & 30 Hz
ripple: don't care too much right now.
My main problem remains understanding why all signal power up to 300
Hz falls away, when i'm filtering until 30Hz.
| |
| Rune Allnor 2006-09-29, 8:06 am |
|
GJB skrev:
> Stop band attenuation: 50dB
> corner frequencies: 10 & 30 Hz
> ripple: don't care too much right now.
Then the specification is incomplete.
> My main problem remains understanding why all signal power up to 300
> Hz falls away, when i'm filtering until 30Hz.
I plotted the frequency response of the coefficients you posted.
It seems OK to me.
Are you sure there are energy in the signal below 300 Hz?
Could it be a factor 10 blunder somewhere in your code,
say a number that should have been 1250 was written as
12500, or something like that?
Rune
| |
| Scott Seidman 2006-09-29, 8:06 am |
| "Rune Allnor" <allnor@tele.ntnu.no> wrote in news:1159535212.788102.286730
@k70g2000cwa.googlegroups.com:
> Then the specification is incomplete.
My own experience is that passband ripple specs aren't so important for
(maximally flat) Butterworth designs, as you can't get much better than
Butterworth, but phase considerations can get very important.
--
Scott
Reverse name to reply
| |
| Rune Allnor 2006-09-29, 8:06 am |
|
Scott Seidman skrev:
> "Rune Allnor" <allnor@tele.ntnu.no> wrote in news:1159535212.788102.286730
> @k70g2000cwa.googlegroups.com:
>
>
>
> My own experience is that passband ripple specs aren't so important for
> (maximally flat) Butterworth designs, as you can't get much better than
> Butterworth, but phase considerations can get very important.
You are right, technically speaking, but it is hard to analyze
a filter if it isn't well-defined. There are certain differences
between a 3 dB ripple spec and a 0.1 dB ripple spec. The posted
coefficients give the 3 dB frequency at 30 Hz while the 0.1dB
frequency is near 50 Hz.
It does help to know what one is looking for.
Rune
| |
| bulent serdaroglu 2006-09-29, 8:06 am |
| hello,
I have used "your code", and it seems okey to me ? it was exactly
filtering out the required band...
just to show you the example :
order=5; % just a possible order
signal=randn(1,10000); % a fullband signal
[b,a] = butter(order,30/1250,'high');
signalnew= filtfilt(b,a,signal);
figure,plot(abs(fft(signalnew,2500))) ;
now if you can see that the transition occurs at "approximateley"
30th sample
it means no problem..
note: I have used abs value of fft instead of its square, but less
strictly you can use it to chechk for frequency band of signal...at
least to chechk the band of a filter..
hopefully helpful
B.S.
GJB wrote:
>
>
> Rune Allnor wrote:
> highpass filter
and[color=darkred]
> filtered
300[color=darkred]
> hz.
it?[color=darkred]
>
> Stop band attenuation: 50dB
> corner frequencies: 10 & 30 Hz
> ripple: don't care too much right now.
>
> My main problem remains understanding why all signal power up to
> 300
> Hz falls away, when i'm filtering until 30Hz.
| |
|
| > Then the specification is incomplete.
The specification may be incomplete, but above 30Hz the signal should
be ok, or shouldn't it?
> I plotted the frequency response of the coefficients you posted.
> It seems OK to me.
I plotted it as well, it seems OK to me too. Just after I apply
filtfilt the filtered signal is not what i expect to be.
> Are you sure there are energy in the signal below 300 Hz?
Yes, I plot the energy before and after filtering. Below 300 is where
pretty much all of the energy is.
> Could it be a factor 10 blunder somewhere in your code,
> say a number that should have been 1250 was written as
> 12500, or something like that?
It is not a factor 10 blunder. There isn't that much code involved,
so i'm pretty sure.
It must be something pretty obvious I'm afraid, but i just can't get
it right.
| |
| Rune Allnor 2006-09-29, 8:06 am |
|
GJB skrev:
>
> The specification may be incomplete, but above 30Hz the signal should
> be ok, or shouldn't it?
No one can answer that unless you specify what the frequency
response should be at 30 Hz. That's why I say the specification
is incomplete.
>
> I plotted it as well, it seems OK to me too. Just after I apply
> filtfilt the filtered signal is not what i expect to be.
Then it's pretty obvious where you ought to look for a problem,
right? There is a problem either with the filtfilt command or with
how you plot the signal. It shouldn't be hard to check which it is.
>
> Yes, I plot the energy before and after filtering. Below 300 is where
> pretty much all of the energy is.
>
>
> It is not a factor 10 blunder. There isn't that much code involved,
> so i'm pretty sure.
You're wasting everybody's time! "Pretty sure" isn't good enough.
Either the code works or it doesn't. You have refused to come
up with a complete spec for the filter, but even so, the response
seems reasonable given the incomplete spec.
The filtfilt call seems OK at first glance (I haven't used filtfilt for
ages and I haven't bothered with the documentation), so what
remains are two factors:
1) Does the input signal contain any energy at all below 300 Hz?
2) Is there a problem with the plotting routines?
> It must be something pretty obvious I'm afraid, but i just can't get
> it right.
You can. You have all the arguments you need, and have had
them for a number of posts now. You are just not willing to
work through the program at the necessary level of detail.
Rune
|
|
|
|
|