Period Operator Using filtfilt

6 views (last 30 days)
Coulton
Coulton on 20 Sep 2012
I am trying to understand the function filtfilt, but I am having difficulties wrapping my head around it. I believe it may be because I am unsure of what one of the operations is in the help document for filtfilt. The operation is: y=filtfilt(d.Numerator,1,x);
What does d.Numberator do?

Answers (2)

Wayne King
Wayne King on 21 Sep 2012
Edited: Wayne King on 21 Sep 2012
The answer to what the period operator in your example does is the following.
filtfilt() unlike filter() does not accept a dfilt object input. The portion of the example you are showing is using a dfilt object. What you have is an FIR filter dfilt object, so the example is extracting the numerator coefficients (in the Numerator field) and providing those to filtfilt.m.
For example:
x = randn(10000,1); % just create some noise to filter
% Design a lowpass FIR filter with a sampling rate of 1 kHz
D = fdesign.lowpass('Fp,Fst,Ap,Ast',100,150,1,40,1000);
d = design(D,'equiripple'); % design FIR equiripple filter
Now you cannot filter data using filtfilt() with
y = filtfilt(d,x); % this will error
% However the following works
y = filter(d,x);
So to use filtfilt.m, you have to extract the numerator coefficients. For an FIR filter the denominator coefficient is 1.
y = filtfilt(d.Numerator,1,x);

Jan
Jan on 21 Sep 2012
Edited: Jan on 21 Sep 2012
Do you understand the command filter? If not look at first to doc filter. You find a M-version here: Answers: Filter Constants.
Now filtfilt does the following:
  1. Create some initial conditions to reduce the transitional effects on the margins. This is a kind of warm-up the filter.
  2. Filter from start to end and backwards from end to start. This eliminates the delay effects: With a single filter, the values of a point depends on its predecessors, such that a peak is shifted to the right. Filtering in backward direction again shifts it to the left again.

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!