How to interpolate a set of data with the cubic method?
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Pipe
el 29 de Sept. de 2022
Comentada: John D'Errico
el 29 de Sept. de 2022
I tried looking it up, and it comes out that i should use the spline command, but when i use it nothing comes out. I need to plot the data and the interpolant. I also need to find x for when y= 600
x = [74 29 21 12 8 5.7 4.4 3.6 2.1 1.8 1.5 1.0 0.7];
y = [80 131 189 270 320 407 450 530 620 686 740 900 1095];
s = spline(x, y, 600);
3 comentarios
John D'Errico
el 29 de Sept. de 2022
Note that this is rather noisy looking data, and it has large changes in slope. That makes a cubic spline a terribly poor choice to model that curve, even if it appears it survived the process and produced a monotonic curve. Using a higher order interpolant to model noise is often a bad idea.
Instead, use pchip, a tool designed not to introduce spurious extrema and non-monotonic behavior into a problem. The curve will still come out looking smooth.
Respuesta aceptada
KSSV
el 29 de Sept. de 2022
x = [74 29 21 12 8 5.7 4.4 3.6 2.1 1.8 1.5 1.0 0.7];
y = [80 131 189 270 320 407 450 530 620 686 740 900 1095];
yi = linspace(min(y),max(y)) ;
xi = interp1(y,x,yi,'spline') ;
plot(x,y,'*r',xi,yi,'b')
x_600 = interp1(y,x,600,'spline') ;
1 comentario
John D'Errico
el 29 de Sept. de 2022
Note that this is rather noisy looking data, and it has large changes in slope. That makes a cubic spline a terribly poor choice to model that curve, even if it appears it survived the process and produced a monotonic curve. Using a higher order interpolant to model noise is often a bad idea.
Instead, use pchip, a tool designed not to introduce spurious extrema and non-monotonic behavior into a problem. The curve will still come out looking smooth.
Más respuestas (0)
Ver también
Categorías
Más información sobre Smoothing 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!