about the built-in matlab function decimate
5 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
In the matlab function 'decimate', the input signal is firstly lowpass-filtered, then downsampled.
In the code, I found that
odata = filtfilt(b,a,idata);
nbeg = r - (r*nout - nd);
odata = odata(nbeg:r:nd);
So, after the lowpass, the downsampling selects points from 'nbeg' rather than the first point, giving rise to a shift in the decimated signal. Why?
0 Commenti
Risposta accettata
Walter Roberson
il 5 Mag 2015
http://www.mathworks.com/help/signal/ref/decimate.html under Algorithms indicates
When using the FIR filter, decimate filters the input sequence in only one direction. This conserves memory and is useful for working with long sequences. In the IIR case, decimate applies the filter in forward and reverse directions using filtfilt to remove phase distortion. This in effect doubles the filter order. In both cases, the function minimizes transient effects at both ends of the signal by matching endpoint conditions.
My thought is that what you are seeing is the part about matching endpoint conditions.
decimate is, according to the documentation, often used upon chunks of the data. In order for that to work smoothly so that you can paste the results back together, you would want to avoid the first few samples of the filter result, as those correspond to the filter values not yet initialized, which is probably equivalent to the case where you were picking up in the middle of filtering an array that had an indefinite number of 0s before the data of interest. Transients caused by the initialization. So you skip the affected output samples and end up with something that can be smoothly combined with the previous or next chunk.
1 Commento
K E
il 23 Nov 2015
Is a workaround to pad the time series at the start/end with a 'reflection' (first/last xx points, but in reverse order), apply the filter, then throw out the fake data at the start/end? I have seen this done.
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Multirate Signal Processing in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!