Upsampling the data using interpolation gives NaN values.

조회 수: 10 (최근 30일)
Ajay Kumar
Ajay Kumar 2019년 9월 26일
편집: Ajay Kumar 2019년 10월 7일
Hello everyone,
I have the data of size 2173x1. I want to increase the number of samples to length of 2225570x1 using interpolation/resampling.
I tried using interp1 function and ended up having the required length, but NaN values after 2173 samples.
Thanks in advance.

채택된 답변

Star Strider
Star Strider 2019년 9월 26일
Use the 'extrap' argument in interp1.
Example —
D = load('x.mat');
x = D.x;
v = 1:numel(x);
ve = 1:2225570;
x_extended = interp1(v, x, ve, 'linear','extrap');
This is dangerous, because you have no idea what ‘x’ actually would be beyond its current definition. I would definitely avoid that.
However you can completely avoid all those problems if you simply want more points in ‘x’:
vr = linspace(min(v), max(v), 2225570);
x_resampled = interp1(v, x, vr);
Experiment to get the result you want.
  댓글 수: 2
Ajay Kumar
Ajay Kumar 2019년 9월 26일
Yes, I have tried 'extrap' before, and that goes beyond the maximum limit of original data and I simply neglected it.
But anyways, the linspace thing worked out. Thanks :)
Star Strider
Star Strider 2019년 9월 26일
As always, my pleasure!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

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