Plot curve through data points

38 ビュー (過去 30 日間)
Marcus Boyd
Marcus Boyd 2023 年 1 月 14 日
コメント済み: Marcus Boyd 2023 年 1 月 14 日
Hi,
I am trying to plot a curve line through a set of points as showin in my drawing
I am using the following code to interpolate, but it is giving me the wrong graph.
x = [15.9, 16.9, 17.5, 19.6];
v = [1.108287307, 1.130052358, 1.118465615, 1.102750628];
xi = [x(1):0.0000001:x(end)];
vid=interp1(x,v,xi,'spline');
plot(x,v,'b*')
hold on
plot(xi,vid,'r')
Any help would be appreciated,
Thanks.

採用された回答

the cyclist
the cyclist 2023 年 1 月 14 日
You can use a different interpolation method. pchip looks like what you want:
x = [15.9, 16.9, 17.5, 19.6];
v = [1.108287307, 1.130052358, 1.118465615, 1.102750628];
xi = [x(1):0.0000001:x(end)];
vid=interp1(x,v,xi,'pchip');
figure
plot(x,v,'b*')
hold on
plot(xi,vid,'r')
  1 件のコメント
Marcus Boyd
Marcus Boyd 2023 年 1 月 14 日
That's brilliant, thanks very much

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

その他の回答 (0 件)

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by