How to use a (virtual) bus as input to a referenced model
Show older comments
Ich am creating a virtual bus in a model which hosts a nested submodel.
I want to pass that virtual bus to the nested model which in turn shall have a single inport (In-)Block.
Unfortunately the input is not being recognized as being fed by a bus (i.e. when using a bus selector after the input port) no Elements are being shown when trying to simulate the model.
Is there a way to achieve that simulink detects the bus elements automatically once the models are being simulated together?
If not, what is the easiest way of exporting the information about the content of the virtual bus from the hosting model and import it to specify the the child models input?
Answers (2)
Aabha
on 9 Jun 2025
0 votes
I understand that you are using a virtual bus to pass data to a model reference. In Simulink, if you use a virtual bus as an input or an output for a referenced model, the bus cannot contain a variable-size signal element. This might be the reason behind the bus elements not being visible while using the bus selector block. For more details regarding model referencing signal requirements and limitations, please refer to the documentation link below: https://www.mathworks.com/help/releases/r2025a/simulink/ug/model-referencing-limitations.html#brazo0l
If you wish to transfer data to the referenced model using bus elements, you can convert the virtual bus to a non-virtual bus. The following documentation link shows an example in which a subsystem is converted to a referenced model, and bus elements are used as input to the referenced model: https://www.mathworks.com/help/releases/r2025a/simulink/slref/converting-subsystems-to-model-reference.html
Additionally, to create bus objects during the conversion of a subsystem to a model reference, you can use the ‘Simulink.SubSystem.convertToModelReference’ function with the ‘CreateBusObjectsForAllBuses’ argument set to true. Please refer to the documentation of the above function for more information: https://www.mathworks.com/help/releases/r2025a/simulink/slref/simulink.subsystem.converttomodelreference.html
I hope this helps.
4 Comments
Marcus
on 10 Jun 2025
Aabha
on 10 Jun 2025
Simulink does not treat unspecified datatypes as 'variable-sized' signals. If variable sized signals are not being used in the model, the referenced model should be able to take virtual buses as inputs. I tried to reproduce the issue you are facing using a simple model (attached), and I was able to access the nested buses inside the referenced model from the parent model through bus selector blocks.
Please refer to the following documentation link for more information about how output signals of the 'Bus Selector' block can be set programatically: https://www.mathworks.com/help/releases/r2025a/simulink/slref/busselector.html#f6-1418226_sep_OutputsList
I hope this helps.
Aabha
on 10 Jun 2025
The issue moght be that model 'b' was created first, with an input signal to the 'Bus Selector' block which was not a bus, and then referenced in the parent model. I tried replicating the same subsystem that you have created in 'b', and then converted it into a model reference using the following commands:
blk = "a/b1";
newmdl = "b1";
Simulink.SubSystem.convertToModelReference(blk,newmdl, ReplaceSubsystem = true);
This method seems to be working fine at my end.
I hope this is helpful to you.
The question is quite old but I want to add my solution in case someone else ends up having the same problem in the future.
I was facing the same issue, and Simulink was throwing an error in the referenced model that the input signal was not the correct bus. The problem seems to be that when you use a normal "Inport" block and the input signal is a virtual bus, Simulink does not recognize the output signal of the port as a bus, even if it is connected to a "Bus Selector".
A better alternative is to use an "In Bus Element" at the interface of the referenced model instead of a normal Inport. Note that it is possible to have the full bus at the output of the In Bus Element, just leave the signal field empty, something like this:

Then, you can explicitly define the signals inside of the bus by double-clicking on the In Bus Element (for detailed instructions, see the example "Define Input Bus Without Extra Blocks or Bus Objects" in the In Bus Element help page).
Categories
Find more on Simulink in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!