MATLAB: Do I receive an error when I have a Manual Switch block whose output is a bus signal that feeds back into one of the input ports of the Switch

busesbussessimulink

I have a Manual Switch block whose output is a bus signal. The bus signal loops back into one of the input ports of the switch. The other input port is fed by a Bus Creator block. When I update the model I get the following error:
Selected signal 'Bus1.Subbus1.Signal1' in 'origcustmodel3/Equations Of Motion/Bus Assignment' is not part of the bus entering the Bus Assignment block.
However, my bus signal "Subbus1" does have the signal "Signal1" (specified using bus objects).

Best Answer

The error is due to the fact that the Manual Switch block is not bus capable. The Simulink documentation has information on the list of Bus-Capable nonvirtual blocks. The following is the list of nonvirtual blocks in Simulink 6.4 (R2006a) that are bus capable
Memory, Merge, Switch, Multiport Switch, Rate Transition, Unit Delay, Zero-Order Hold.
To work around this issue, you can use the Switch block instead of the Manual Switch block. If you need the functionality of a Manual Switch Block, you can use the regular Switch block with a Constant block feeding into the switch port. You can use it like a manual switch by setting the constant accordingly. You can further do the following to make it behave like a Manual Switch. You can set the "OpenFcn" callback for the Constant block so that when you double click on the Constant block, it automatically flips the constant value. This makes it act like a Manual switch. The attached example model shows how this can be achieved.