Unexpected NaN output from power block
Show older comments
While building my model I came across the following integrator error:
- Derivative of state '1' in block 'simpie/Motor & PI Current Controller/Integrator' at time 4.519405258285984 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)
After some investigation I found by setting the INF or NaN block output to warning that there are NaN values that are contaminating my feedback loop which in turn raises the integrator error. By setting the INF or NaN block output setting to warning I tried to figure out where the first NaN value comes from. This raises the following error:
An error occurred during simulation and the simulation was terminated
Caused by:
- Block 'simpie/Controller/Power1' outputs 'NaN' for element 1 of output port 1 at minor time step 4.51941
From reading the documentation about the power block, it became clear that the block will output a NaN value from an NaN input. I assume that there is no NaN input into the power block since this is the first NaN output. I tried to use the isnan block to monitor the generated NaN value without succes. The block does not recognice any NaN output. The error occurs at a specific point in time where the value into the power block for the base come close to zero (See the included figure). The exponent is a constant.

Strangely the simulation works fine for t<1 which also has an input of 0 for the power block.
Does anyone have a clue what causes this problem and how to fix it?
Thank you in advance
3 Comments
Vinay
on 17 Dec 2024
Hi @Quint, could you please share your Simulink model file so I can better understand the issue?
Walter Roberson
on 17 Dec 2024
I suggest that instead of testing using isnan() that you instead test ~isfinite() as that also tests for +/- inf
Quint
on 17 Dec 2024
Accepted Answer
More Answers (0)
Categories
Find more on Simulink Functions in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!