How to interpolate a set of data with the cubic method?
4 次查看(过去 30 天)
显示 更早的评论
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 个评论
John D'Errico
2022-9-29
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.
采纳的回答
KSSV
2022-9-29
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 个评论
John D'Errico
2022-9-29
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.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Splines 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!