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

조회 수: 2 (최근 30일)
Stephen
Stephen 2016년 2월 3일
답변: Stephen 2016년 8월 15일
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?

채택된 답변

Kiran
Kiran 2016년 2월 8일
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.

추가 답변 (1개)

Stephen
Stephen 2016년 8월 15일
As an update, in newer versions bus objects can be stored in a Data Dictionary file.

카테고리

Help CenterFile Exchange에서 Model, Block, and Port Callbacks에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by