error when using lsqnonlin with 'levenberg-marquardt' algorithm

조회 수: 3 (최근 30일)
Kukhokuhle Tsengwa
Kukhokuhle Tsengwa 2021년 5월 6일
답변: Shiva Kalyan Diwakaruni 2021년 5월 12일
When using lsqnonlin, I am getting the error:
  1. Derivative of state '1' in block 'armDynamics/Integrator' at time 1.9771760646058036 is not finite. The simulation will be stopped. There may be a singularity in the solution. If not, try reducing the step size (either by reducing the fixed step size or by tightening the error tolerances)
I have set:
options = optimoptions(@lsqnonlin, 'Algorithm','levenberg-marquardt', 'Display','off','StepTolerance',0.001,'OptimalityTolerance',0.001);
Any assistance would be appreciated.

답변 (1개)

Shiva Kalyan Diwakaruni
Shiva Kalyan Diwakaruni 2021년 5월 12일
Hi,
This problem occurs when an integrator is present in the model.
Open Configuration Parameter, set the diagnostic "Inf or NaN block output" to error, you will get the error as follows:
An error occurred while running the simulation and the simulation was terminated
Caused by:
  • Block 'BlockName' outputs 'NaN' for element x of output port x at major time step 0 where BlockName is the block in which error is thrown.
This blocks has a divide by zero, which creates a Inf that when fed to an Integrator, generates this error.
So, avoid division by zero in the logic.
Hope it helps.

카테고리

Help CenterFile Exchange에서 Modeling에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by