How to plot cubic spline

1 回表示 (過去 30 日間)
Frank Battillo
Frank Battillo 2018 年 12 月 7 日
回答済み: Image Analyst 2018 年 12 月 7 日
I'm trying to plot my cubic spline at the end of my code. I figure out how to get the data point needed to plot, but I can't figure out to get the graph to work.
My matrix with Y,B,C,D look like this
plotwo =
Columns 1 through 3
5.0000 1.0144 0
6.0000 0.9713 -0.0431
6.5000 -0.3995 -1.3278
5.5000 -0.8732 0.8541
5.5000 0.8923 0.9115
Column 4
-0.0144
-0.4282
0.7273
0.0191
-0.3038
This is what I tried the code always starts at x=1,2,3
xx=h;%x cords
for i=1:+1:d-1
y=plotwo(i,1)+ plotwo(i,2)*(x-i)+plotwo(i,3)*((x-i)*(x-i))+plotwo(i,4)*((x-i)*(x-i)*(x-i));
fplot(xx,y,'*');
hold on
end
  1 件のコメント
madhan ravi
madhan ravi 2018 年 12 月 7 日
interp1()?

サインインしてコメントする。

回答 (1 件)

Image Analyst
Image Analyst 2018 年 12 月 7 日
Simply use the built in spline() function. See attached demo.

カテゴリ

Help Center および File ExchangeSplines についてさらに検索

タグ

製品


リリース

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by