Why does resample lose values when applied to vector with NaN's?
5 views (last 30 days)
Show older comments
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!
0 Comments
Answers (1)
Akira Agata
on 10 May 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.
0 Comments
See Also
Categories
Find more on Multirate Signal Processing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!