### Tags: 30hz, butterworth, commandsb, filter, highpass, matlab, problemi, programming, sampled, signal, thissignal

# Butterworth filter

On Programmer » Matlab

6,516 words with 9 Comments; publish: Fri, 09 May 2008 23:47:00 GMT; (20078.13, « »)

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?

*http://matlab.todaysummary.com/q_matlab_5750.html*

All Comments

Leave a comment...

- 9 Comments
- 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

#1; Fri, 09 May 2008 23:48:00 GMT

- GJB skrev:
- 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.

#2; Fri, 09 May 2008 23:49:00 GMT

- Rune Allnor wrote:
- 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

#3; Fri, 09 May 2008 23:50:00 GMT

- GJB skrev:
- Rune Allnor wrote:
>

> GJB skrev:

highpass filter

filtered

hz.

> 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.

#4; Fri, 09 May 2008 23:51:00 GMT

- Rune Allnor wrote:
- 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

#5; Fri, 09 May 2008 23:52:00 GMT

- GJB skrev:
- "Rune Allnor" <allnor.matlab.todaysummary.com.tele.ntnu.no> wrote in news:1159535212.788102.286730
.matlab.todaysummary.com.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

#6; Fri, 09 May 2008 23:53:00 GMT

- "Rune Allnor" <allnor.matlab.todaysummary.com.tele.ntnu.no> wrote in news:1159535212.788102.286730
- Scott Seidman skrev:
> "Rune Allnor" <allnor.matlab.todaysummary.com.tele.ntnu.no> wrote in news:1159535212.788102.286730

> .matlab.todaysummary.com.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

#7; Fri, 09 May 2008 23:54:00 GMT

- Scott Seidman skrev:
- 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

> filtered

300

> hz.

it?

> 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.

#8; Fri, 09 May 2008 23:55:00 GMT

- hello,
- > 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.

#9; Fri, 09 May 2008 23:56:00 GMT

- > Then the specification is incomplete.