MATLAB: Do subsystems feeding bus signals into a Switch block not execute conditionally

busbussesconditionsimulink

I have a model in which I use a Switch block to switch between two bus signals. The two bus signals feeding into the Switch block are generated by atomic subsystems upstream of the Switch block. I stepped through the model execution and I observed that both atomic subsystems are executed at every time step irrespective of which bus signal is passed through by the Switch block. This is not the case if the signals feeding into the Switch block are non-bus signals.

Best Answer

What you are seeing is that conditional execution is not being applied because this is no longer a simple switch. If you examine the execution order you will notice that the relevant Switch block (Which is named: mysoup1\Switch1 in the example below) is actually two blocks while the model is running.
From the debugger:
(sldebug @62): >> slist
---- Sorted list for 'mysoup1' [11 nonvirtual blocks, directFeed=0]
0:0 'mysoup1/Constant1' (Constant, tid=1)
0:1 'mysoup1/TmpAtomicSubsysAtSwitchInport1' (SubSystem, tid=1)
0:2 'mysoup1/TmpAtomicSubsysAtSwitchInport3' (SubSystem, tid=1)
0:3 'mysoup1/Switch' (Switch, tid=1)
0:4 'mysoup1/Display' (Display, tid=1)
0:5 'mysoup1/Subsystem' (SubSystem, tid=1)
0:6 'mysoup1/Constant3' (Constant, tid=1)
0:7 'mysoup1/Subsystem1' (SubSystem, tid=1)
0:8 'mysoup1/Switch1/Switch1_1' (Switch, tid=1)
0:9 'mysoup1/Switch1/Switch1_2' (Switch, tid=1)
0:10 'mysoup1/Display1' (Display, tid=1)
The bus has two signals in it, and this switch block converts into two switches to handle them. For some of the blocks that support bus signals, this method of expanding the bus with multiple blocks is the way that they are implemented. Given that this is a composite signal this is the current expected behavior.