How to filter data in a temporally causal way?
2 views (last 30 days)
Show older comments
I'm trying to filter a signal, but I've encountered something that I'm not sure how to overcome at the moment.
I am trying to implement a filter that would work in the same manner in offline filtering as in online filtering. What I mean is, the filter should act in a causal way; it shouldn't "read the next few data points" to decide how to alter the current signal.
If I try:
band=[100 200]
sampfreq=1000;
[A,B]=butter(4,band/sampfreq*2);
data=zeros(10000,1);
data(5000:5100)=1;
fdata=filtfilt(A,B,data);
figure;hold on;
plot(data,'b');plot(fdata,'r');
xlim([4900,5200]);
Then it results in the following figure:

This doesn't make sense to me as a model of an online filter because it violates causality; the red ripples appear in the filtered data before the change occurs in the input data. How can I design a filter which works in a causal way and only responds to changes in the input that have already occurred from a temporal standpoint?
Thank you.
0 Comments
Answers (0)
See Also
Categories
Find more on Digital Filtering in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!