Hello, I´ve been using matlab since a few years now for data manipulation and non linear fitting. So I´m feeling quite dumb not being able to solve this. Perhaps the problem arises from the fact that I´ve been using matlab 2017 and 2018 up to recently and I had to switch to R2012b recently.
Attached are the x and y data I´d been trying to fit with a simple exponential decay. The code I´m using is the following
fun=@(x,I) x(1)+x(2).*exp(-I/x(3));ub=[1 100 1000];lb=[1e-5 1e-5 10];x0=[1.17e-4 0.00272 114.31287];options=optimset('MaxIter',2000,'TolFun',1.e-5,'TolX',1.e-5,'Algorithm', ...'trust-region-reflective',... 'MaxFunEvals',2000,'Display','iter');x = lsqcurvefit(fun,x0,xdata,ydata,lb,ub,options);
The seed values are correct. I get the following error
Error using snls (line 48) Objective function is returning undefined values at initial point. lsqcurvefit cannot continue.
I don´t get whats wrong, the objective function looks defined at the initial point to me.
Thanks in advanced.
Luis
Best Answer