I have a masked subsystem in Simulink, containing a Matlab-function. The Matlab-function generates a structure as an output, based on an input provided in the mask. I would like to have a bus at the output of my subsystem which contains the elements of that structure.
The way I see it, I have to define the bus information to which the bus should adhere before Simulink knows how to deal with it. But I need to do this within the mask, as only the mask has the information to generate said information.
I tried to implement Simulink.Bus.createObject in the mask Initialization, which works, but I cannot find a way of defining a name of the bus in that function. As such, Simulink defaults to it's naming scheme slBus1, slBus2 ... As such, I can label my bus to be of the type slBus1 (if I pass it through the mask). But that only works if there was no slBus1 a priori and each time I evaluate the mask, my workspace gets cluttered with new buses. Furthermore, I cannot access the information written to the base workspace to change e.g. the name (which I can detect), because it is not accessible to the masked Workspace.
I also tried fully defining the bus within the mask Initialization using Simulink.Bus and Simulink.BusElement, but then the bus only exists within the masked Workspace and the bus information should be on the base Workspace for Simulink to use it.
If there would be a way of defining a name for the Simulink.Bus.createObject, that would solve my issues. But any other solution will do.