MATLAB: Upsampling the data using interpolation gives NaN values.

interpinterp1interpolationMATLABresampleupsample

Hello everyone,
I have the data of size 2173×1. I want to increase the number of samples to length of 2225570×1 using interpolation/resampling.
I tried using interp1 function and ended up having the required length, but NaN values after 2173 samples.
Thanks in advance.

Best Answer

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.