Smoothing a curve and conserving the first and the last value of the curve

10 ビュー (過去 30 日間)
Hannes Frey
Hannes Frey 2021 年 9 月 17 日
コメント済み: Star Strider 2021 年 9 月 20 日
Hi all,
I am trying to smooth a simple curve with evenly spaced sample points which starts e.g. at 1 for t0 and ends at 0 for t1. Can I force the smoothing algorythm (e.g. smoothdata()) to conserve the first and the last value of the curve such dat the smoothed curve also starts at 1 at t0 and ends at 0 at t1?
Thanks a lot!

採用された回答

Star Strider
Star Strider 2021 年 9 月 17 日
Probably the only way to do that is to use the 'SamplePoints' name-value pair, and smooth all but the beginning and end points —
x = 1:25;
y = randn(size(x));
ys = smoothdata(y(2:end-1), 'SamplePoints',x(2:end-1));
figure
scatter(x, y, 'p')
hold on
plot(x, [y(1) ys y(end)], '-r')
hold off
grid
.
  2 件のコメント
Hannes Frey
Hannes Frey 2021 年 9 月 20 日
Thank you!
Star Strider
Star Strider 2021 年 9 月 20 日
As always, my pleasure!
.

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

その他の回答 (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