curve fitting with dependencies between the coefficients
2 views (last 30 days)
Show older comments
Hello everybody,
I have a problem to fit a curve to my data, because I cannot set dependencies between the coefficients of the fit!
The function is: w1*(1-exp(-a1*(t^n1))) + w2*(1-exp(-a2*(t^n2))) + w3 *(1-exp(-a3*(t^n3)))
And the secondary contion should be: w1 + w2 + w3 == 1
%% Fit:
[xData, yData] = prepareCurveData( [], conversion );
ft = fittype( 'w1*(1-exp(-a1*(t^n1))) + w2*(1-exp(-a2*(t^n2))) + w3 *(1-exp(-a3*(t^n3)))', 'independent', 't', 'dependent', 'y' );
opts = fitoptions( 'Method', 'NonlinearLeastSquares' );
opts.Display = 'Off';
opts.Lower = [1e-08 1e-08 1e-08 0.9 0.5 1.5 0 0 0];
opts.StartPoint = [0.001 0.001 0.001 1 0.5 2 0.333 0.333 0.333];
opts.Upper = [1 1 1 1.1 0.6 3.5 1 1 1];
% Fit model to data.
[fitresult, gof, output] = fit( xData, yData, ft, opts );
I also tried the optimization tool, but I couldn´t solve my problem
I would realy appreciate if somebody could help me
0 Comments
Answers (1)
Matt J
on 19 Nov 2020
Edited: Matt J
on 19 Nov 2020
Re-express your model function as,
sin(d1)^2*(1-exp(-a1*(t^n1))) + cos(d1)^2*sin(d2)^2*(1-exp(-a2*(t^n2))) +...
cos(d1)^2*cos(d2)^2*(1-exp(-a3*(t^n3)))
and the constraint will be innately satisfied with
w1=sin(d1)^2
w2=cos(d1)^2*sin(d2)^2
w3=cos(d1)^2*cos(d2)^2
Or, use fmincon and impose linear equality constraints directly.
2 Comments
Matt J
on 20 Nov 2020
You're welcome, but please Accept-click the answer if it resolved your problem.
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!