How to plot a smooth curve with only a few points?

480 ビュー (過去 30 日間)
Herline van der Spuy
Herline van der Spuy 2021 年 9 月 13 日
Hi,
I have 6 data points, it's very little, but it's all I have. How do I get a smooth plot from that? Like Excel has the option, by I want to use matlab.
time = PENO(:,1);
s24 = PENO(:,2);
sx24 = smooth(s24)
plot(time,sx24,'-o','Color',blue,'LineWidth',1.5,'MarkerSize',5,'MarkerFaceColor',blue);
This is what I get: The blue line is the original plot, without the smooth. And then I tried to smooth, which is the black line.

採用された回答

Jan
Jan 2021 年 9 月 13 日
Either decide for a linear interpolation:
x = 1:6;
y = rand(1, 6);
plot(x, y, 'ko');
hold on
xx = linspace(1, 6, 100);
yy1 = interp1(x, y, xx, 'cubic');
plot(xx, yy1, 'r-');
yy2 = interp1(x, y, xx, 'spline');
plot(xx, yy2, 'b-');
yy3 = interp1(x, y, xx, 'makima');
plot(xx, yy3, 'c-');
Or if you know the function of your data, fit a model to the measured values.
  1 件のコメント
Herline van der Spuy
Herline van der Spuy 2021 年 9 月 14 日
Brilliant! Thank Jan. I really appreciate this.

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

その他の回答 (0 件)

カテゴリ

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

タグ

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by