Error in Integrator block

9 views (last 30 days)
Parth Bipin
Parth Bipin on 29 Sep 2024
Commented: Sam Chak on 6 Oct 2024
Error:An error occurred during simulation and the simulation was terminated
Caused by:
Derivative of state '1' in block 'HW02_2024_SimulinkModel/VD model/velocity' at time 64.05749999999999 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)
at my integrator block.
  1 Comment
Sam Chak
Sam Chak on 29 Sep 2024
The system you constructed in Simulink is unstable. This instability may be caused by human error in modeling the system dynamics or by incorrectly applied parameter values.

Sign in to comment.

Answers (1)

Yukthi S
Yukthi S on 4 Oct 2024
This error occurs often possibly because of the following reasons:
Reason-1: An Inf or NaN output caused by a block in the model at that particular time instant.
Solution-1: Firstly, you can check for singularity in the Simulink model by navigating to Configuration parameters>Diagnostics>Data Validity and set Inf or NaN block output to error and run the model
If this is the issue, 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 which caused this error.
After identifying the block, you can debug further and avoid passing Inf or NaN values to the integrator.
Reason-2: Bigger step size
Solution-2: If no error was found after setting Inf or NaN block output to error, try reducing the step size. Try using ODE15s (Stiff/NDF) as solver.
Go to Model Configuration parameters (Ctrl+E) > Solver and adjust
  • Type: Variable-step
  • Solver: ode15s (stiff/NDF)
Reason-3: Unstable system of equations, basically a divergent system.
Solution-3: If the above two solutions did not work, the error might be because of unstable system and can be fixed by:
  • Run the model using the step forward function (run step by step).
  • Starting from the integrator block that makes the model stop, click on signals to display values.
  • Track the signal until you find where the value diverges.
  • make the necessary corrections.
Hope this is helpful!
  5 Comments
Parth
Parth on 6 Oct 2024
Thank you my model did work
Sam Chak
Sam Chak on 6 Oct 2024
Good to hear that, @Parth Bipin, (or @Parth). Please consider accepting @Yukthi S's answer since the issue is solved now.

Sign in to comment.

Products


Release

R2024a

Community Treasure Hunt

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

Start Hunting!