about the built-in matlab function decimate

5 ビュー (過去 30 日間)
Ray Lee
Ray Lee 2015 年 5 月 5 日
コメント済み: K E 2015 年 11 月 23 日
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?

採用された回答

Walter Roberson
Walter Roberson 2015 年 5 月 5 日
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 件のコメント
K E
K E 2015 年 11 月 23 日
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.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMultirate Signal Processing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by