How to interpolate a set of data with the cubic method?
2 ビュー (過去 30 日間)
古いコメントを表示
この 質問 は Star Strider
さんによってフラグが設定されました
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!