Why does the output of an If Action Subsystem seem to hold the last computed value?

5 views (last 30 days)
I am using a couple If Action Subsystems with an If block in Simulink. I have connected the outputs of the If Action Subsystems to a scope block, and the results I see are not what I was expecting.
The If Action Subsystems seem to hold the last-known value rather than resetting to zero. This means I can't add the outputs to achieve my desired output. How can I make these signals reset to zero when the subsystem isn't active?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 25 Jun 2021
This behavior is by design. We recommend using a Merge block to consolidate the outputs from If Action Subsystems, as the Merge block will automatically select the most recently-computed input as its output.
For more information about the Merge block, please see the following documentation page: https://www.mathworks.com/help/simulink/slref/merge.html
The following documentation page provides usage examples for the If Action Subsystems, with the recommended workflow of using a Merge block to consolidate the signals:
There is a way to force the individual If Action Subsystem outputs to reset to 0 or another provided value when they are no longer active. 
To define this reset behavior:
1. Double click on one of the If Action subsystems
2. Double click on the Out block inside the subsystem (Out1 by default)
3. Select "Output when disabled" to be "reset" instead of "held"
4. Define Initial Output as 0 or another desired value to reset to
5. Do the same workflow for the other If Action subsystems

More Answers (0)

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!