user1331843
user1331843

Reputation: 123

using options in lsqcurvefit

I set my options to

options=optimset('LevenbergMarquardt', 'on')

and then employ lsqcurvefit like below,

[x,resnorm,residual,exitflag,output] = lsqcurvefit(@myfun, [0.01 0.3], xdata, ydata, [-inf -inf], [inf inf], options)

but the problem is that I don't now why I will get for output :

output =

firstorderopt: 3.4390e-07
   iterations: 4
    funcCount: 15
 cgiterations: 0
    algorithm: 'large-scale: trust-region reflective Newton'
      message: [1x425 char]

Does this mean Matlab did not use the algorithm Levenberg Marquardt?

But I did set my options to levenberg Marquardt algorithm!!!

I'd appreciate any help.

Upvotes: 2

Views: 1554

Answers (2)

antijon
antijon

Reputation: 1002

I can't say for certain, but the constaints ([-inf -inf], [inf inf]) could be your problem. The documentation for lsqcurvefit strictly says the LMA cannot be used for constrained problems. If constraints are included, it will fall back to trust-region.

Yes, your constraints are mathematically equivalent to 'no constaints', but I have no idea how the MATLAB function itself will interpret those. I tried to recreate the problem on my end, but optimset('LevenbergMarquardt', 'on') has been deprecated and generates an error (implying you have a relatively old version). Even when using the new syntax (optimset('Algorithm', 'levenberg-marquardt')), it behaves correctly on my end (using 2011b). To not have constraints, the correct approach is to use empty matrices (i.e. []).

Yes, the question is a month old, but someone else may find the answer useful.

Upvotes: 1

Shai
Shai

Reputation: 114816

Sometimes a specific algorithm is not suitable for a specific configuration of an optimization problem. In these cases Matlab "falls back" to its default optimization algorithm.
It might be the case that for your specific problem/configuration Matlab is unable to use Levenberg-Marquardt algorithm.

Read the docs carefully to see if this is the case.

Upvotes: 2

Related Questions