Why does resample lose values when applied to vector with NaN's?

조회 수: 7 (최근 30일)
dl_86
dl_86 2018년 5월 9일
답변: Akira Agata 2018년 5월 10일
I am resampling a vector with a few final values equal to NaN. The output of resample.m is shorter than expected. Could somebody explain why this happens? According to MATLAB manual , NaN's should be safely ignored.
Here's the code that reproduces the problem:
test = [randn(80,1); nan(20,1)];
resampled = resample(test,1,3);
figure, plot(test,'b')
hold on, plot(1:3:100,resampled,'r')
downsampled = downsample(test,3);
hold on, plot(1:3:100,downsampled,'k')
and the figure:
Note that "downsample" doesn't have this problem.
resample.m and firls.m are the ones provided by MATLAB:
which resample
C:\Program Files\MATLAB\R2014b\toolbox\signal\signal\resample.m
which firls
C:\Program Files\MATLAB\R2014b\toolbox\signal\signal\firls.m
Thank you!

답변 (1개)

Akira Agata
Akira Agata 2018년 5월 10일
The function downsample decreases the sampling rate by extracting every n-th sample. On the other hand, resample applies an antialiasing FIR filter when changing the sampling rate. That's the reason why outputs of these function differ each other.

카테고리

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