Basic filtering related question
1 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
回答(1 个)
Wayne King
2011-11-4
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 个评论
Wayne King
2011-11-4
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)');
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Single-Rate Filters 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!