Search All of the Math Forum:

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

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

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

 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

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

Date Subject Author
9/12/09 hans
9/12/09 stefano Mangione
9/12/09 hans
9/12/09 stefano Mangione
9/12/09 hans
12/13/09 Yow Cheong Kok
12/13/09 Wayne King
12/18/09 Yow Cheong Kok
12/20/09 Yow Cheong Kok
5/15/13 Fernan