How to use a (virtual) bus as input to a referenced model

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)

Hi @Marcus,
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

Hi @Aabha,
thanks for your reply. I have read those pages you quote but unfortunately they do not answer the questions for me.
First, I do not have variable sized signals in my bus, unless of course simulink sees all signals that are not specified by a data type (other then inherit / -1) as variable sized. I assume that is the case then?
If so and i need to convert to non-virtual the question remains on how to export the required Simulink.Bus specification from an existing model or signal respectively. So I have a bus with nested busses in the referenced model and need to get the 'Bus: myBusSpecification' from that model to use it in the parent model. (Creating it by hand is not an option, I need to derive it from the model by matlab code)
Is there an easy way to get this specification from out of the referenced model?
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 I am using R2022b, so I cannot open your model. edit used R2024b to open it but the submodel is missing.
Please see my testmodels attached.
I neither can access the bus elements a/b in the nested model, nor the buselements x/y in the parent model.
When opening / double clicking the bus selectors, nothing is shown for elements in the bus.
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.

Sign in to comment.

Ali Reza
Ali Reza on 6 Mar 2026
Edited: Ali Reza on 6 Mar 2026
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

Products

Release

R2022b

Asked:

on 5 Jun 2025

Edited:

on 6 Mar 2026

Community Treasure Hunt

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

Start Hunting!