Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TugboatEng on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

anybody know the difference between filter and filtfilt

Status
Not open for further replies.

mapi

Mechanical
Joined
Jan 30, 2007
Messages
53
Location
US
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
 
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
 
Thanks. I will read the help file carefully again.

Mapi
 
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



 
Is this for school?

TTFN

FAQ731-376
 
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top