Unexpected NaN output from power block
10 views (last 30 days)
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
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
Accepted Answer
Vinay
on 18 Dec 2024
Edited: Vinay
on 18 Dec 2024
The occurrence of 'NaN' output when the base of the power block is close to zero is due to the "Power Signedness" functionality of the power block.
To avoid the 'NaN' output when an even order root is used as the power value, the "Signed power" option should be enabled.

Refer to the below documentation of power block for more details on the "Signed Power" functionality:
I hope this would resolve the issue!
More Answers (0)
See Also
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!