custom fitting / additional boudary conditions on parameters

조회 수: 1 (최근 30일)
Onufry Torbus
Onufry Torbus 2015년 2월 5일
댓글: Onufry Torbus 2015년 2월 7일
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
Torsten
Torsten 2015년 2월 6일
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.
Onufry Torbus
Onufry Torbus 2015년 2월 7일
I made a mistake before, I edited this and now should look more clear

댓글을 달려면 로그인하십시오.

채택된 답변

Torsten
Torsten 2015년 2월 5일
Use fmincon to be able to account for your constraints.
Best wishes
Torsten.
  댓글 수: 3
Torsten
Torsten 2015년 2월 5일
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.
Onufry Torbus
Onufry Torbus 2015년 2월 6일
편집: Onufry Torbus 2015년 2월 6일
Dear Torstane,
I am beginner with Matlab and the environment is not always clear for me. I read the documentation of fmincon. As far as I understood I have to prepare mfunction file first (in a separate m file) and then make a call in my m script (curve fitting).
1. I created a file "objfun.m" as:
function f = objfun(x)
f = sum((y(i)-f(t(i))^2, i=1..n) % I am not sure if this is correct...
2.Now the call in my script:
ft = fittype(['A*((1-f1-f2-f3)*t+g1*t1*(1-exp(-t/t1))+g2*tau2*(1-exp(-t/t2))+g3*t3*(1-exp(-t/t3)))'],'independent', 't', 'dependent', 'y' );
opts = fitoptions( ft );
opts.Display = 'Off';
A = [1 1 1] % constraints
B = [0] % constraints
g0 = [0.1;0.3;0.6]; % Starting guess
[g,fval] = fmincon(@objfun,x0,A,B);
opts.Lower = [_Inf g(1) g(2) g(3) 0 0 0];
opts.StartPoint = [0 g0(1) g0(2) g0(3) 1 10 100];
opts.Upper = [Inf g(1) g(2) g(3) Inf Inf Inf];
Am I heading in good direction?

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Linear and Nonlinear Regression에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by