How to filter data in a temporally causal way?
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (0)
Voir également
Catégories
En savoir plus sur Digital Filtering dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!