0

I'm trying to use Nonlinear Data-Fitting and lsqnonlin in Matlab to find parameter (a) of my equation. The code doesn't have any error but the plot which Matlab is suggesting, starts at a different initial value than the points I have so I can't find the correct value for the parameter (a).

This is my code. Can you help me find the plot which is fitted to my points and the correct value for parameter (a)?

x = [0, 24, 48, 72, 96];
y = [0.16 * 10^8, 0.18 * 10^8, 0.35 * 10^8, 0.62 * 10^8, 1.41 * 10^8];
plot(x,y);
a = optimvar('a', 1);
x0.a = [0];
diffun =  10^10 * exp(-exp(-a*x));
diffexpr = sum((diffun - y).^2);
ssqprob = optimproblem('Objective',diffexpr);
[sol,fval,exitflag,output] = solve(ssqprob,x0);
resp = evaluate(diffun,sol);
hold on
plot(x,resp)
hold off
Robert
  • 7,394
  • 40
  • 45
  • 64
  • Are you sure of your model equation diffun = 10^10 * exp(-exp(-a * x)) ? This is not consistent with the data. If one consider the more general model diffun = b * exp(-c * exp(-a * x)) the non linear regression gives the value of b very different from 10^10 and the value of c very different from 1. The cause of your difficulty might be a typo or a mistake in the model equation. – JJacquelin Mar 04 '23 at 11:20

0 Answers0