Parameters estimation using lsqcurvefit

Hi I am trying to do parameter estimation following the code prepared by Star Strider ‘Igor_Moura'. I have added several differential equations and edited the code. But it does not run. I would really appreciate it if you would help me to solve my problem. Thank you.
Always I receive the following message : Failure in initial user-supplied objective function evaluation. LSQCURVEFIT cannot
continue.
Attached the script
Please help

 Accepted Answer

I did not see this originally, or I would have responded to it several days ago.
The code needed some tweaks (that I will let you find, referring to the ‘Igor-Moura.m’ code will make this easier). I attached it here. It now runs, and produces:
Rate Constants:
p(1) = 5.09562
p(2) = 0.02642
p(3) = 3.25429
p(4) = -0.28403
p(5) = 1.06602
p(6) = 16.32329
p(7) = 0.20617
p(8) = 3.98434
p(9) = 1.38866
p(10) = 4.19445
p(11) = -5.18517
p(12) = 0.05000
p(13) = 0.67375
p(14) = 0.22527
p(15) = -0.22388
p(16) = 12.31547
p(17) = 14.00000
p(18) = -5.37072
p(19) = 79.89868
p(20) = -0.27531
p(21) = 19.43315
p(22) = 0.88034
p(23) = 20.60852
p(24) = 2.81029
p(25) = -0.48154
p(26) = 3.54883
p(27) = 0.07324
p(28) = 2.13279
p(29) = 1.30150
p(30) = 0.24330
p(31) = 121.96400
p(32) = 2.20000
p(33) = 2.20000
Adding:
for k = 1:size(yexp,2)
subplot(8,2,k)
plot(t, yexp(:,k), 'p')
hold on
plot(tv, yfit(:,k), '-r')
hold off
title(sprintf('Column %2d',k))
end
after the ‘yfit’ assignment demonstrates that the fit is not close, however now that the code runs, you can work on fixing it so that it produces better results.

4 Comments

@Star Strider Thank you so much for your answer
unfortunately it didn't run and I didn't understand why. I got the following error
>> Mouna_YAHYA_kinetics
Warning: Failure at t=1.724809e+01. Unable to meet integration tolerances without reducing
the step size below the smallest value allowed (5.684342e-14) at time t.
> In ode15s at 669
In Mouna_YAHYA_kinetics>kinetics at 6
In lsqcurvefit>objective at 261
In snls at 338
In lsqncommon at 150
In lsqcurvefit at 253
In Mouna_YAHYA_kinetics at 118
Error using -
Matrix dimensions must agree.
Error in lsqcurvefit/objective (line 262)
F = F - YDATA;
Error in snls (line 338)
newfvec = feval(funfcn{3},xcurr,varargin{:});
Error in lsqncommon (line 150)
[xC,FVAL,LAMBDA,JACOB,EXITFLAG,OUTPUT,msgData]=...
Error in lsqcurvefit (line 253)
[xCurrent,Resnorm,FVAL,EXITFLAG,OUTPUT,LAMBDA,JACOB] = ...
Error in Mouna_YAHYA_kinetics (line 118)
[p,Rsdnrm,Rsd,ExFlg,OptmInfo,Lmda,Jmat]=lsqcurvefit(@kinetics,p0,t,yexp);
Could you please see it again
thank you
As always, my pleasure!
That is a Warning, not an error, and indicates that ode15s (necessary to run this) encountered a singularity at that point and could not continue. These are caused by what is essentially a division-by-0 or an exponential or similar function approaching . You need to go through your code to understand where that occurred, and why. (Most times, this is related to an initial condition, or a coding error.) I do not understand what your code does, so my efforts were limited to getting it to run.
I will help as I can, however for situations such as this, you need to find the problem and then fix it.
okay I will see thank you for your answer
As always, my pleasure!

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!