MATLAB: For many vectors of data of different length, how to interpolate to set them all to have the same length

datainterpolationMATLAB

I'm analyzing a series of data vectors, each of which has a different number of points, but the x-coordinate of the data spans 1 to ~2800. My simulations have 1400 points, so I need to interpolate the data vectors to properly sample the y-coordinate of the data while ending up with all interpolated data vectors at a length of 1400. Are there any helpful tricks? I know "resample()" would do the trick, but I'm not able to purchase the signal processing toolbox, so that's not an option.

Best Answer

Use interp1()
Demo:
xdata = 1:280;
ydata = 10:150;
xdataResamp = linspace(xdata(1),xdata(end),numel(ydata));
ydataInterp = interp1(xdataResamp,ydata,xdata);
% Visually inspect results
figure()
plot(xdataResamp,ydata, 'b-o')
hold on
plot(xdata, ydataInterp, 'r-s')