×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Are you an
Engineering professional?
Join Eng-Tips Forums!
• Talk With Other Members
• Be Notified Of Responses
• Keyword Search
Favorite Forums
• Automated Signatures
• Best Of All, It's Free!

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

#### Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

# anybody know the difference between filter and filtfilt

## anybody know the difference between filter and filtfilt

(OP)
Hi,
I want to filter some experimental data: y=f(x),---smooth the y values. But I have tried both filter and filtfilt, what is the difference between them? Or which one is better?

Mapi

### RE: anybody know the difference between filter and filtfilt

filtfilt() implements filter() twice.  first forwards, then backwards.  You get twice the attenuation and zero phase shift.  So filtfilt() is probably what you want.  I have a vague recollection that filtfilt() is only in the signal processing toolbox?  If so it wouldn't take too many brain cells to implementy it by hand.

- Steve

### RE: anybody know the difference between filter and filtfilt

(OP)
Thanks. I will read the help file carefully again.

Mapi

### RE: anybody know the difference between filter and filtfilt

hello,

i also need some help regarding this filtfilt thingy..
the thing is.. i am supposed to check the phase response using both functions to see the differences. i just dunno where to start..

some of the lines that i have written..

b=[1];
a=[1, -0.8];
w=0:0.1:10;

x=sin(w);
y=filter (b,a,x);

figure(1);
subplot(2,1,1);
plot (w,x);
subplot(2,1,2);
plot(w,y);

[H]=freqz (b,a,w);
figure(2);
subplot(2,1,1);
plot(w,abs(H));
subplot(2,1,2);
plot(w,angle(H));

y1=filtfilt (b,a,x);
figure (3);
plot(w,y1);

[H1]=freqz (b,a,w);
figure (4);
subplot(2,1,1);
plot(w,abs(H1));
subplot(2,1,2);
plot(w,angle(H1));

it is obvious that both phase response are the same bcos they still use the same (b,a,w).. so what should i do?

and another question.. how can i obtain the phase shift of both y and y1 from the curve??

can i just read from the curve or is there any other function that i am not aware of??

thanks..

regards

newbie with matlab

### RE: anybody know the difference between filter and filtfilt

Is this for school?

### RE: anybody know the difference between filter and filtfilt

It must be.  He has managed to enlist Rune in one of his identical postings on CSSM.  But has made a complete hash of the advice given.

- Steve

#### Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

#### Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Close Box

# Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

• Talk To Other Members
• Notification Of Responses To Questions
• Favorite Forums One Click Access
• Keyword Search Of All Posts, And More...

Register now while it's still free!