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

5 Ansichten (letzte 30 Tage)
dl_86
dl_86 am 9 Mai 2018
Beantwortet: Akira Agata am 10 Mai 2018
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!

Antworten (1)

Akira Agata
Akira Agata am 10 Mai 2018
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.

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by