How to use a (virtual) bus as input to a referenced model
8 views (last 30 days)
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?
0 Comments
Answers (1)
Aabha
on 9 Jun 2025
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
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.
See Also
Categories
Find more on Component-Based Modeling 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!