How to interpolate a set of data with the cubic method?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Pipe
am 29 Sep. 2022
Kommentiert: John D'Errico
am 29 Sep. 2022
Diese(r) Frage wurde durch Star Strider
markiert
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 Kommentare
John D'Errico
am 29 Sep. 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.
Akzeptierte Antwort
KSSV
am 29 Sep. 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 Kommentar
John D'Errico
am 29 Sep. 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.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Splines finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!