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

조회 수: 6 (최근 30일)
Adam Truelove
Adam Truelove 2017년 10월 23일
편집: Nathan 2017년 10월 24일
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에서 Programmatic Model Editing에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by