Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: zero phase low pass filter - filtfilt and IFIR
Replies: 9   Last Post: May 15, 2013 4:25 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Yow Cheong Kok

Posts: 36
Registered: 6/19/06
Re: zero phase low pass filter - filtfilt and IFIR
Posted: Dec 18, 2009 10:53 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

Hi Wayne,

Thanks for your 2 suggestions. I have tested both on my voice sample as follows but the result is still the same ie have delay effects.

Sorry for the slow feedback coz I was away for other assignment. May i know your email address ? so i can send the voice sample to you to verify or do you have further suggestion ? Thanks

[x, Fs] = wavread('c:\wav\sample.wav');
Hd = fdesign.lowpass('Fp,Fst,Ap,Ast',1000,1200,0.5,60,10000);
D = design(Hd,'equiripple');
% Now you can call filtfilt() with the numerator coefficients
Y = filtfilt(D.Numerator,1, x);
wavwrite(Y, 'c:\wav\filter\sample_new.wav');

[x, Fs] = wavread('c:\wav\sample.wav');
Hd = fdesign.lowpass('N,F3dB',15,1000,10000);
D = design(Hd,'butter');
[B,A]= sos2tf(D.sosMatrix,D.ScaleValues);
fvtool(B,A) % still looks fine
y = filtfilt(B,A,x);
wavwrite(y, 'c:\wav\filter\sample_new.wav');

regards,
Yow

>
> Hi Yow, and others,
> Yes, it is true that filtfilt() does not currently accept filter objects as inputs, but you can still take advantage of the flexibility and strength of fdesign.<response> and simply extract the filter coefficients to use in filtfilt(). This is straightforward in the case of an FIR filter:
>
> Hd = fdesign.lowpass('Fp,Fst,Ap,Ast',1000,1200,0.5,60,10000);
> D = design(Hd,'equiripple');
> % Now you can call filtfilt() with the numerator coefficients
> Y = filtfilt(D.Numerator,1,randn(1024,1));
>
> In the case of an IIR filter, it's a bit trickier since those are implemented as biquad filters. You can use sos2tf() to extract the filter coefficients, but in this case I caution you to be careful because the higher the order of the IIR filter, the more numerical problems due to round off may occur in the SOS to transfer function conversion.
> For example:
> % Notice I pick a fairly low order filter here
> Hd = fdesign.lowpass('N,F3dB',8,1000,10000);
> D = design(Hd,'butter');
> [B,A]= sos2tf(D.sosMatrix,D.ScaleValues);
> fvtool(B,A)
>
> % You can up the filter order, but again always view your resulting transfer function
> % to see if it has been affected by numerical problems
> Hd = fdesign.lowpass('N,F3dB',15,1000,10000);
> D = design(Hd,'butter');
> [B,A]= sos2tf(D.sosMatrix,D.ScaleValues);
> fvtool(B,A) % still looks fine
> y = filtfilt(B,A,randn(1024,1));
>
> The above procedure should allow you to use filtfilt() and still take advantage of fdesign.<response> and their associated design methods.
>
> Hope that helps,
> Wayne




Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.