lsqcurvefit five parameter estimation with piecewise continuous function
Afficher commentaires plus anciens
I am attempting to use lsqcurvefit to optimize the estimation of five parameters in piecewise continuous function simultaneously, however my script is returning the following error: "Error using symengine. Array sizes must match."
Any comments/suggestions on how to correctly estimate the parameters for this function would be much appreciated.
%%Test parameters and symbolic variables
syms tau
gam=0.01;
t0=11;
%%Simulated stress response to ramp strain and hold experiment
ramp_time=[0,3,9,10.9];
ramp_stress=[0,30,400,455.2];
hold_time=[11.5,23.8,29.8,34.1,38.2,45.2,70.3,84.6,91.3];
hold_stress=[428.6,324.1,267.3,243.2,228.1,213.1,199.6,198.7,198.5];
time=[ramp_time,hold_time];
stress=[ramp_stress,hold_stress];
%%Curve fitting
fun = @(x,time) ((x(1)*x(2)*gam/(1+x(3)*log(x(4)/x(5))))*int((1+x(3)*(igamma(0,(ramp_time-tau)/x(4))-igamma(0,(ramp_time-tau)/x(5))))*exp(x(2)*gam*tau),tau,0,t0)).*(time<t0)+((x(1)*x(2)*gam/(1+x(3)*log(x(4)/x(5))))*int((1+x(3)*(igamma(0,(hold_time-tau)/x(4))-igamma(0,(hold_time-tau)/x(5))))*exp(x(2)*gam*tau),tau,0,t0)).*(time>=t0);
x0=[10,300,300,1,1000]; % Initial guess
options = optimoptions('lsqcurvefit','Algorithm','levenberg-marquardt');
lb=[];
ub=[];
x = lsqcurvefit(fun,x0,time,stress,lb,ub,options);
Réponses (1)
Matt J
le 16 Fév 2016
0 votes
I suggest you forget about lsqcurvefit for the moment and concentrate on getting your objective function to successfully evaluate at x0. It is there that the error is being generated.
5 commentaires
Matthew
le 17 Fév 2016
For whatever reason, I'm finding that the time required to evaluate fun(x,hold_time) is very non-repeatable and also can very greatly with x. This may be due to some quirk of the Symbolic Toolbox functions. I don't know if it is wise to use symbolic integration (or symbolic anything else) in conjunction with a numerical minimization routine like lsqcurvefit. If you have the Statistics Toolbox, I imagine that GAMINV might do a better job of those inverse gamma integrals...
Matthew
le 19 Fév 2016
Matthew
le 19 Fév 2016
Matt J
le 19 Fév 2016
Yes, I think it is preferable, but of course you should test it.
Catégories
En savoir plus sur Solver Outputs and Iterative Display dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!