How do I fit two equations that explain two parts of a curve?
Show older comments
Hi,my equations are: y(t)={(a/b)*(1-exp(-b(x-x_start)),for x_start <= x < x_end %equ1 and {c*exp(-b(x-xend)),for x > x_end %equ2
Here I do not know a,b and c. The idea is that since both equations have b in common, I would like to know how fitting these equations I can get one single value for b. I already fitted these equations individually, but I obtained two values of b, which are different from each fit.
1 Comment
John D'Errico
on 17 Feb 2015
I predict that your next question will be why is my curvefit not continuous at the break point? I.e., at x_end, the pair of functions will not be continuous.
Accepted Answer
More Answers (1)
Joep
on 17 Feb 2015
This is very simple solution which works in some cases one thing you need to noticed is the 1-based indexing of matlab.
a=10; b=20; c=-1; d=-3;
for x=1:a
t(x)=x;
y(x)=c*x;
end
for x=a:b
t(x)=t;
y(x)=d*x.^2;
end
figure
plot(t,y)
Categories
Find more on Choose a Solver in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!