Why does the If Action subsystem throw an error when the subsystem is not even supposed to get called while using Simulink 7.4 (R2009b)?

28 views (last 30 days)
I have a model which has the 'Inf or NaN block output' diagnostic set to error and the 'Inline Parameters' option checked. The model is designed in such a way that it should not execute the If subsystem and should always go to the else subsystem.
However, when I run this model, I receive the follwoing error:
Block '<modelname>/If_Action_Subsystem/<blockname>' output 'Inf' for element 1 of output port 1 at major time step 0.000000

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 25 Sep 2009
This behavior occurs because the 'Inline Parameters' option changes the behavior of the blocks depending on their sample time.
If there are blocks with 'Inf' sample time in the model, e.g. Constant blocks, then that sample time may be propagated to some other blocks including the ones that are inside the If Action subsystem. Constant sample times means that the value of the block is not changing throughout the simulation and therefore will get evaluated once during initialization.
The optimization for block reduction is done after block initialization. While the initialization are still computed, the model will not recompute the block during simulation due to block reduction.
When inline parameter is turned on, here are a couple of workarounds:
1. To avoid the warning during simulation, remove 'inf' sample times and instead use the base sample time of the model. Therefore the values will not get evaluated during initialization, and optimizations like block reduction will only compute the necessary blocks to get the output.
2. For code generation, you can turn on "inline invariant signals" option as well. This will further optimize the generated code to inline signals that are not changing throughout simulation. If you decided to use the inf sample time, turning on this option would avoid the generation of rtinf.

More Answers (0)

Products


Release

R2009b

Community Treasure Hunt

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

Start Hunting!