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!