Can I store a Bus object outside of the base workspace?

2 views (last 30 days)
I have a model where I am re-using library blocks (atomic reusable function.) I'd like to be able to define the parameters required for each library block using a bus object, so that I can data type the parameters with the bus object, so each function will have a bus object for its parameters. From what I can see the bus objects must be stored in the base workspace, as individual items. This results in me having a lot of bus objects in my base workspace, making it very messy. Is there a way I can store these with the model? Or is there a way I can structure these within the base workspace to organise it better?

Accepted Answer

Kiran
Kiran on 8 Feb 2016
As far as I know, Bus Objects are created in base workspace only. There is no any direct way to create Bus objects in a model workspace.
There is a workaround which would allow Model Reference Library Blocks to use Bus Objects that are not in a separate file and would not pollute the workspace with the created Bus Objects. The bus object can be programmatically created in the Initialization callback of a model which is being referenced by a model reference block. The block objects can then be erased in the StopFcn callback so that no bus objects would be left in the workspace after the model is done executing.
However, this workaround is not scalable as it would require all busses to be created manually in the Initialization callback.

More Answers (1)

Stephen
Stephen on 15 Aug 2016
As an update, in newer versions bus objects can be stored in a Data Dictionary file.

Community Treasure Hunt

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

Start Hunting!