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 CenterFile Exchange에서 Multirate Signal Processing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by