custom fitting / additional boudary conditions on parameters
1 view (last 30 days)
Show older comments
Hi there,
I am working on a custom curve fitting. It is a set of exponential functions, see below. My problem is that I have to apply constraints on paramateres g1, g2 and g3, in a way that: g1 + g2 + g3 = 1.
Can you help me out? /OT
ft = fittype(['E0*((1-g1-g2-g3)*t+g1*tau1*(1-exp(-t/tau1))+g2*tau2*(1-exp(-t/tau2))+g3*tau3*(1-exp(-t/tau3)))'],'independent', 't', 'dependent', 'y' );
opts = fitoptions( ft );
opts.Display = 'Off';
opts.Lower = [0 0 0 0 0 0 0];
opts.StartPoint = [0 0 0 0 1 10 100];
opts.Upper = [Inf 1 1 1 Inf Inf Inf];
2 Comments
Torsten
on 6 Feb 2015
I just looked at the type of fit you defined in your question.
If you want f1+f2+f3=1 in the above fittype, the factor in front of t, namely 1-f1-f2-f3, becomes zero. Is this really what you intend ?
Best wishes
Torsten.
Accepted Answer
Torsten
on 5 Feb 2015
Use fmincon to be able to account for your constraints.
Best wishes
Torsten.
3 Comments
Torsten
on 5 Feb 2015
As objective function, you provide
sum_{i=1}^{n} (y_i-f(t_i))^2
with
f(t)=A*((1-f1-f2-f3)*t+g1*t1*(1-exp(-t/t1))+g2*tau2*(1-exp(-t/t2))+g3*t3*(1-exp(-t/t3)))
and as constraints your lower and upper bounds for the parameters to be fitted together with the additional constraints from above.
Read the documentation of fmincon on how to set up the call:
Best wishes
Torsten.
More Answers (0)
See Also
Categories
Find more on Linear and Nonlinear Regression 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!