How do I perform a segmented regression for linear and exponential piecewise curve
14 ビュー (過去 30 日間)
古いコメントを表示
Hi, everyone! I simulated this signal where the first segment is linear (constant), second segment is linear (positive gradient) and the third segment is an exponential decay. Is there a way for me to do a piecewise regression with 3 line segments - linear, linear and exponential? Thank you very much.
p/s: I think this is my first ever post, so I might not know the rules on how to ask a question proper, so if more information is needed, please let me know what other info I should provide! Thanks!
0 件のコメント
回答 (2 件)
Saksham Gupta
2022 年 7 月 5 日
編集済み: Saksham Gupta
2022 年 7 月 5 日
As per my understanding , you wish to know how to perform segmented regression in MATLAB.
You should try Curve Fitter App of MATLAB with your data set, using 'Interpolant' or 'Smoothing Spline' as fit type might be helpful with the dataset of your kind.
Here are a few file exchanges that you might find helpful as well:
Sam Chak
2022 年 7 月 5 日
編集済み: Sam Chak
2022 年 7 月 5 日
Hi @Luqman
There are 3 segments defined over certain intervals of t:
a constant
a straight line
and an exponential decay
So, the piecewise model probably look something like this:
t = linspace(0, 520, 52001);
x1 = 100*((0 <= t) & (t < 80));
x2 = (((600 - 100)/(120 - 80))*t - 900).*((80 <= t) & (t < 120));
x3 = 600*exp(-0.0025*1.7918*(t - 120)).*((120 <= t) & (t < 520));
x = x1 + x2 + x3;
plot(t, x, 'linewidth', 2), grid on,
xlim([0 520]), ylim([0 700])
2 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!