How to create a spline for data without sorting?
Mostrar comentarios más antiguos
Hello,
I have some data that represents trajectories through the 2D plane. My requirements:
- I need a pchip type spline to interpolate between the points. The default MATLAB function first sorts the points and this destroys the trajectory.
- I need to be able to divide up the splined path between successive points along the path into a given number of equal spaced segments.
Here are my points and the number of equal spaced points I need between each par (including the endpoints):
x = [218.0264 217.5283 217.4984 217.5386 217.1662 217.0156 218.0268 218.3743 218.3370 218.1877 218.0228 218.0729];
y = [276.9834 278.3856 278.6099 279.1224 280.0742 280.3255 279.0974 278.1296 277.3735 278.1461 275.6485 276.5042];
C = [13 13 15 19 29 31 9 11 3 35 31];
I found the excellent code by John D'Errico (INTERPARC) will solve the first requirement. The problem is that while it does fit a smooth spline between the points, and preserve the order, I can't figure out how to generate the equal spaced points between each pair. Rather, his program generates equal spaced points along the entire curve. So I need the curve his code generates if it passes through the dat points, but I need the equal spacing to include the x and y data as part of the sampling by including equal spaced pairs in between each.
Here is a plot of the spline fit returned by INTERPARC with 800 equal spaced points. I need to use this curve, fit to the entire data set, but I need to be able to segment between each pair of points along the way from point 1 to the final point according to vector C. So I need points along this curve but 13 points between (x(1),y(1)) and (x(2),y(2)) that include the endpoints, and so for each pair.

Any idea how I can accomplish this?
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Splines en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

