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

5 ビュー (過去 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 Center および File ExchangeMultirate Signal Processing についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by