How do I perform a segmented regression for linear and exponential piecewise curve
14 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (2)
Saksham Gupta
el 5 de Jul. de 2022
Editada: Saksham Gupta
el 5 de Jul. de 2022
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
el 5 de Jul. de 2022
Editada: Sam Chak
el 5 de Jul. de 2022
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 comentarios
Ver también
Categorías
Más información sobre Get Started with Curve Fitting Toolbox en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!