How to save Bus Object with all dependent Bus Objects to a file programmatically?

13 次查看(过去 30 天)
I have a script that creates several bus objects in the workspace. There is one main bus object with many bus objects nested inside the main one with several layers. I need to save them all to a file. The problem is, the script won't know the names of the bus objects other than the top level one. So I need to somehow save the top level bus object with all its dependent bus objects. I can do this via the bus editor very easily. You just right click on the bus object and choose "Export of bus object with Dependent Bus Objects to File". That's exactly the functionality I want, but I need to be able to do it programmaticaly. Is this possible?

回答(1 个)

Nathan
Nathan 2017-10-24
编辑:Nathan 2017-10-24
You can create a Cell array from the top level Simulink Bus and then save that cell array:
topLevelCellArray = topLevelBusName.objectToCell; save('filename.mat','topLevelCellArray);
And then when you load the cell array into the the base workspace again convert it to Simulink bus objects: load('filename.mat'); Simulink.Bus.cellToObject(topLevelCellArray)

类别

Help CenterFile Exchange 中查找有关 Component-Based Modeling 的更多信息

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by