MATLAB Answers

lsqcurvefit: Local minimum possible... but clearly visible minima

23 views (last 30 days)
Ralf Schmauder
Ralf Schmauder on 1 Mar 2021
Answered: Alan Weiss on 1 Mar 2021
I optimze a parameter (it is not an f(x) type dependence) on a dataset with lsqcurvefit. I always get "Local minimum possible"
However, if I ran manual loop and plot the sum of the squared residues, a minima is visible.
With default options, I get resonable results when starting from low numbers, e.g.10, when starting from higher values I get apparent minima ranging from 3000-7000 are found. Reason is likely the "roughness" of the squared residues vs. the parameter:
With playing with 'FunctionTolerance' the system now finds values ~ 2444, already quite good but not the actual mnima of 2398. Apperently the programm gets stuck in rather local mimima.
Are there any options I am missing?
Are there better ways than using lsqcurvefit?
I do not need a very accurate parameter, natural numbers woudl be suffitient.
Surely I coudl always run a loop through all posible parameters, but I hoped to save time with lsqcurvefit.
Surprizingly the "optimize" function ogf IgorPro handles this without problems, But I want too keep everything in MATLAB if possible.
Any advice is apprciated.

Answers (2)

Star Strider
Star Strider on 1 Mar 2021
If you have the Global Optimisation Toolbox, many of those functions (ga is my favourite) will search the entire parameter space for the best parameter set. The point is that an optimisation fundtion that does not use gradient descent will likely be what you want. Another option is fminsearch, however it is not as robust as ga and the others.
Star Strider
Star Strider on 1 Mar 2021
As I understand it, lsqcurvefit requires a function handle as its first argument, implying that you have some sort of functional relationship expression for your objective function with respect to the data. The data themselves may not have been created by a functions, however some sort of relationship appears to exist, as expressed by the objective function you supplied to it, or lsqcurvefit would completely fail.
Seeing your existing code (and perhaps data) and a reasonably detailed description of exactly what you want to do would be helpful.

Sign in to comment.

Alan Weiss
Alan Weiss on 1 Mar 2021
You could try to use fminbnd, which assumes no smoothness and is pretty efficient at 1-D minimization problems.
Alan Weiss
MATLAB mathematical toolbox documentation

Community Treasure Hunt

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

Start Hunting!