In Simulink, the merge block is documentation states
“The Merge block combines its inputs into a single output line
whose value at any time is equal to the most recently computed
output of its driving blocks.”
As clear as that statement is there are still questions about the behavior of the merge block. This post attempts to clarify those questions.
The first and most common question is “what happens when none of my subsystems are enabled/triggered?” In this example, we have 3 subsystems “A”, “B”, and “C” which are enabled when the driving signal is equal to their enumerated namesake. The output from the subsystems is a simple enumerated constant equal to the subsystems name. E.g. subsystem A outputs a value of “A”…
However, the way I have configured the driving signal it includes an enumerated value of “abcs.D” in addition to the A,B,C values.
In this example when the value of the driving signal is equal to abcs.D none of the subsystems are enabled. In this case, the merge block simply outputs the last value input into the system.
Default merge subsystems
In the example above there is an unpredictable behavior due to the lack of a “default” subsystem.
The “Default” subsystem should execute every time step when the other systems are not running. In this example, it is enforced through simple logical operations.
In versions of Simulink from 15a and on (it could be earlier but that is the latest I had installed on my laptop) if you try and execute more then one subsystem during the same time step you will get an error message
In this case, I tried driving my two subsystems “LiveCat” and “DeadCat” with a “Schrodinger Waveform”™ vector. When the vector was in the “Both” mode then both subsystems were active and the error message was triggered.