How run lsqcurvefit correctly?

1 view (last 30 days)
Hi, I'm using lsqcurvefit to find values of sa , for different data input, in a nolinear function. Sometime lsqcurvefit give me correct results but sometime it gives strange results with this message:
Local minimum found. Optimization completed because the size of the gradient is less than the default value of the function tolerance. criteria details
this is the code that I use:
fun1=@(sa,f1)(A.*g.^2./((2.*pi).^4.*f1.^5).*exp(-5./4.*(fp./f1).^4)).*gam.^exp(-0.5.*((f1-fp)./(sa.*fp)).^2);
options=optimset('MaxFunEvals',20000);
options=optimset('TolFun',10^-6);
options=optimset('MaxIter',10000);
options=optimset('TolX',10^-6);
li=0.001;
ls=0.2;
sa_new=lsqcurvefit(fun1,0.07,f1,S1,li,ls,options);
Where A,g,gam,fp are all parametres that I Know and f1 and S1 are the data that I have fit with function. Any suggest to find the correct values of sa? Thanks so much

Accepted Answer

Alan Weiss
Alan Weiss on 7 Sep 2016
Your variable sa seems to be a scalar taking values between 0.001 and 0.2. Have you plotted the sum of squares as a function of sa to see if there are multiple local optima?
FYI, that exit message states that lsqcurvefit has found a local solution. However, there is no guarantee that it found a global solution. Again, I recommend that you plot the function on your interval to see the local optima.
Most likely, the solution to your problem will be to start from a few other points in addition to the fixed 0.07 that you are using, and to take the best solution among the several local optima.
Alan Weiss
MATLAB mathematical toolbox documentation

More Answers (0)

Community Treasure Hunt

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

Start Hunting!