MATLAB Answers


How to solve the block error in the simulink model?

Asked by Priya
on 21 Jan 2014
Latest activity Edited by Walter Roberson
on 9 Jan 2016
When I run my state space model, I get the following error message,
Derivative input 5 of 'statespacemodel_hvm/State-Space' at time 2.2297592983646024 is Inf or NaN. Stopping simulation. 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)
Usually, the simulation diagnostics viewer shows the region where the error has caused, but I can't find it.
Please drop your suggestions as why this error could have occurred.


Could you attach the model and a description of the problem to your question?
Sorry, I'm unable to upload the model.
no solver block connected to physical network. how can I solve this problem

Sign in to comment.


1 Answer

Answer by Mischa Kim
on 21 Jan 2014
Edited by Mischa Kim
on 21 Jan 2014
 Accepted Answer

There are a couple of things you might want to consider:
  • Is the system unstable (by design)? Therefore, does it need to be controlled?
  • If it is stable, there could be a "bug" in the code that makes the system unstable.
  • Third, are you using the right solver and solver settings? Open Simulation > Model Configuration Parameters and check out the solver options. ode45 might be the best choice to get started. Try reducing the absolute and relative tolerances.
  • Lastly, try the debugger .


As you suggested, I think it should be the second one since the system is stable. But then the error seems to have occurred in the state space block of the model.
So, do I have to check the state space equations again?
Following the error mentioned in the previous post, I get another error while running the simulink model which is as below,
Error in port widths or dimensions. Output port 1 of 'statespacemodel_hvm/Mux' is a one dimensional vector with 2 elements.
Please do help me.

Sign in to comment.