Why does resample lose values when applied to vector with NaN's?
5 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
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.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Multirate Signal Processing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!