Basic filtering related question

3 views (last 30 days)
Etienne O'Brien
Etienne O'Brien on 4 Nov 2011
I'm a novice user.
I'm doing a failure test where my displacement (D) increases until a maximum value of Load (L) after which D may increase or decrease. This link shows an example (in this example D continues to increases until data collection stops): http://tiny.cc/4u1of
I use a 5 element moving average filter on both L and D, for example: D= filter(ones(1,5),5,data(:,4)
My problem is, that the filter has introduced a tail at the start of the data where D is decreasing before it increases - this should not happen. Otherwise the filter seems to work just fine - when I overlay the filtered and unfiltered data I am not losing important values as a result of the filter.
My related questions are therefore: (1) Should I use another filter? If so please recommend. OR (2) Is there a simple way of picking out the 'true' start to the data from the filtered data set - where D continually increases to the maximum value of L.
Thank you.

Answers (1)

Wayne King
Wayne King on 4 Nov 2011
Hi Etienne, I don't think your filter is doing exactly what you think. I'm a bit confused by D = filter() since your graph has L as the output variable and D as the input. I'll assume that:
Your filter's difference equation is:
5L(n) = D(n)+D(n-1)+D(n-2)+D(n-3)+D(n-4)
A simple moving average filter is:
L = filter(1/5*ones(5,1),1,D);
As far as avoiding filter transients, have you tried filtfilt() to implement zero-phase filtering?
By the way, if you use a simple moving average filter like above, then the delay with filter() is 1/2 the filter length.
So:
t = 0:0.001:1-0.001;
x = cos(2*pi*100*t);
y = filter(ones(5,1)/5,1,x);
y is delayed 2.5 samples with respect to x.
  3 Comments
Wayne King
Wayne King on 4 Nov 2011
Oh, I thought you had them as a input-output relationship, then I think you want to filter both as:
D= filter(ones(5,1)/5,1,data(:,4)');
L = filter(ones(5,1)/5,1,data(:,5)');
D and L will both be delayed 2.5 samples. You can try filtfilt()
D = filtfilt(ones(5,1)/5,1,data(:,4)');
L = filtfilt(ones(5,1)/5,1,data(:,5)');
Etienne O'Brien
Etienne O'Brien on 5 Nov 2011
Thanks Wayne,
D= filter(ones(5,1)/5,1,data(:,4)');
L = filter(ones(5,1)/5,1,data(:,5)'); %these made no difference
D = filtfilt(ones(5,1)/5,1,data(:,4)');
L = filtfilt(ones(5,1)/5,1,data(:,5)'); %these solved the problem

Sign in to comment.

Tags

Community Treasure Hunt

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

Start Hunting!