For many vectors of data of different length, how do I interpolate to set them all to have the same length?
21 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Blenndrman
el 3 de Sept. de 2019
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.
0 comentarios
Respuesta aceptada
Adam Danz
el 3 de Sept. de 2019
Editada: Adam Danz
el 3 de Sept. de 2019
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')
4 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Multirate Signal Processing en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!