How to avoid unrecognized option names using optimget
Show older comments
I am using lsqcurvefit and receiving errors related to the function lsqncommon. I did not have these errors in the past, so this may be due to changes with more recent versions of Matlab. How can I edit the lines below to avoid these errors? Thank you.
Error 1. "Unrecognized option name 'InitDamping'. See OPTIMSET for possibilities."
Relevant lines of lsqncommon:
algorithm = optimget(options,'Algorithm',defaultopt,optimgetFlag);
initDamping = optimget(options,'InitDamping',defaultopt,optimgetFlag);
if ~iscell(algorithm)
initLMparam = initDamping;
else
initLMparam = algorithm{2}; % Initial Levenberg-Marquardt parameter
algorithm = algorithm{1}; % Algorithm string
end
Error 2. "Unrecognized option name 'ProblemdefOptions'. See OPTIMSET for possibilities."
Relevant lines of lsqncommon:
ProblemdefOptions = optimget(options, 'ProblemdefOptions',defaultopt,optimgetFlag);
FromEqnSolve = false;
if ~isempty(ProblemdefOptions) && isfield(ProblemdefOptions, 'FromEqnSolve')
FromEqnSolve = ProblemdefOptions.FromEqnSolve;
end
8 Comments
Matt J
on 31 Oct 2024
You should not edit MathWorks-authored files. Show us the code that you wrote and are running, and let's discuss changes to that.
Walter Roberson
on 31 Oct 2024
I wonder whether those are options that are present only if you have Global Optimization Toolbox installed?
Luca
on 31 Oct 2024
You need to provide a simplification of your code that we can run and reproduce the error. The code structure you've outlined looks fine, and works fine in the online Matlab engine, as demonstrated below,
[MaxFunEvals,MaxIter,TolFun,TolX,TolOpt]=deal(1e6,100,1e-6,1e-6,1e-6);
function_handle=@(p,xd) xd+p;
X_data=1:5;
Y_data=X_data+pi;
Parameters_Guess=3;
[Parameters_Lower, Parameters_Upper]=deal(0,10);
options = optimoptions('lsqcurvefit', ...
'Display', 'off', ...
'MaxFunctionEvaluations', MaxFunEvals, ...
'MaxIterations', MaxIter, ...
'FunctionTolerance', TolFun, ...
'StepTolerance', TolX, ...
'OptimalityTolerance', TolOpt, ...
'Algorithm', 'trust-region-reflective');
[Parameters_Fit, RSS, residual, exitflag, output, ~, jacobian] = ...
lsqcurvefit(function_handle, Parameters_Guess, ...
X_data, Y_data, ...
Parameters_Lower, Parameters_Upper, ...
options)
Walter Roberson
on 31 Oct 2024
Note that the user is using R2024a, but MATLAB Answers is using R2024b. The lsqncommon routine was rewritten between the two versions, and no longer has the problematic call.
The lsqncommon routine was rewritten between the two versions, and no longer has the problematic call.
I can't find any documentation of that. I don't think we've even identified what the "problematic call" is, because we haven't seen the OP's actual code.
When I run the hypothetical code that I proposed in R2024a, it still runs fine.
Luca
on 31 Oct 2024
Accepted Answer
More Answers (0)
Categories
Find more on Choose a Solver in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!