Why does my filtered time series approach zero as time approaches zero?

5 views (last 30 days)
I have some time series data:
I have built the following filter:
% Build filter
f_samp = 1;
f_nyq = f_samp/2;
f_cutoff = 0.1;
cutoff_norm = f_cutoff/f_nyq;
filt_order = 1;
[B,A] = butter(filt_order,cutoff_norm);
x_smooth = filter(B,A,x);
I apply the filter to the data:
From 10 seconds onwards the data is okay but before this it tends towards zero as t tends towards zero. Does anyone know why this is? Is it a charactersitic of the buuterworth filter or all filters?
I would like to know how to remove this characterstic so that the filtered data is accurate during the first few samples.
Thanks.

Answers (1)

Wayne King
Wayne King on 23 Jan 2013
Edited: Wayne King on 23 Jan 2013
It's because your time series have a large mean value, which makes the start-up effects of the filter much more apparent.
Because it's an IIR filter, it's not trivial to calculate exactly what the length of the start-up transient will be. In the case of an FIR filter, the group delay is often constant and easy to correct for.
You can either:
1.) First remove the mean from your data. Assume X is your signal, you can do
X = X-mean(X);
or
X = detrend(X,0);
2.) Use filtfilt() to perform zero-phase filtering, this should alleviate the start-up transient
y = filtfilt(B,A,X);

Community Treasure Hunt

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

Start Hunting!