Error in Simulink - Derivative of state '1' in block at time 301.02267725 is not finite. The simulation will be stopped. There may be a singularity in the solution.
726 views (last 30 days)
Show older comments
I get the following error -
An error occurred while running the simulation and the simulation was terminated
Caused by:
- Derivative of state '1' in block 'gam_control1/PID Controller2/Integrator/Continuous/Integrator' at time 301.02267725611046 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 am using a manually created signal (using signal editor) as an input into a PID controller. I have tried to select ODE15 from the model configurations and also tried tightening the absolute error. Nothing works. The simulation stops at 300 s. I need it to run till 550 s. Please help.
4 Comments
Sam Chak
on 19 Nov 2023
Moved: Sam Chak
on 3 Oct 2024
Hi @worod
Please post a new question. Despite receiving the same error message, the issue with your FOPID system is different from @Riya Gujarathi's original PID system problem.
federica terlizzi
on 2 Oct 2024
Moved: Sam Chak
on 3 Oct 2024
An error occurred while running the simulation and the simulation was terminated
Caused by:
- Derivative of state '1' in block 'modello1/Transfer Fcn2' at time 0.00525 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)
Che cosa significa? Cosa posso fare?
Answers (2)
Salman Ahmed
on 14 Oct 2021
Hi Riya,
This problem occurs oftenly. This is usually caused because of Inf or NaN output produced at a block. Set the diagnostic "Inf or NaN block output" to error in the configuration settings. 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 in which error is thrown.
You can debug your model from there to bypass NaN or Inf values from reaching the integrator.
3 Comments
Andre Morais
on 26 Jul 2024
Thank you for sharing this piece of information. It was incredibly helpful!
Best regards
Sam Chak
on 3 Oct 2024
% Derivative of state '1' in block 'gam_control1/PID Controller2/Integrator/Continuous/Integrator'
% at time 301.02267725611046 is not finite. The simulation will be stopped. There may be a singularity
% in the solution. If not, try reducing the step size...
Previously, I have asked many students who use Simulink's "Transfer Function" blocks, primarily in courses such as Dynamical Systems and Control Systems, but NONE of them truly understand the meaning of the error message or the suggestion to reduce the step size. They do not learn about "non-finite derivatives" and "singularity" in these courses because the focus is primarily on modeling stable dynamical systems using Laplace transforms and tuning controller gains to achieve stability by evaluating closed-loop poles. These terms are rarely mentioned in the curriculum.
Most of the time, the error indicates that the dynamical system is unstable. In this context, "unstable" means that the output of the transfer function or some of the internal states (in your case, state '#1' is the output) increase or decrease over time without bounds. The output of the system will diverge rapidly, leading to unbounded behavior. Practically speaking, this means that the system's response will grow infinitely (getting non-finite signal), which can cause the system to fail or become uncontrollable. Since Simulink cannot continuously run the simulation without limits, the simulation will be stopped. The term "singularity," in the context of dynamic systems, refers to a condition where the system's equations become undefined or lead to infinite values.
Reducing the step size is a technical adjustment in Simulink that allows the user to specify a much smaller simulation step size (time) to capture the rapidly growing behavior of the system's response. However, in 100% of cases where linear systems are unstable; specifically, where any pole of the transfer function has a positive real part; reducing the step size will not help, as it does not "magically stabilize" the system.
Suggestion:
If the instability is caused by modeling errors due to human mistakes in specifying the system's equations incorrectly (such as plus/minus sign errors, decimal point errors, etc.), these issues must be corrected manually. In almost all cases, users should perform stability analysis of the closed-loop system before running the simulation in Simulink. For linear systems, there are plenty of tools available, such as isstable(), pole(), rlocus(), and eig().
If the instability issue persists, please post your problem along with a screenshot of the Simulink model in a New Question.
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!