How to avoid unrecognized option names using optimget
古いコメントを表示
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 件のコメント
Matt J
2024 年 10 月 31 日
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
2024 年 10 月 31 日
I wonder whether those are options that are present only if you have Global Optimization Toolbox installed?
Luca
2024 年 10 月 31 日
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
2024 年 10 月 31 日
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
2024 年 10 月 31 日
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Choose a Solver についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!