필터 지우기
필터 지우기

Export bus datatype from referenced subsystem

조회 수: 3 (최근 30일)
Lukas
Lukas 2024년 5월 7일
답변: Yatharth 2024년 5월 22일
I have created a nested bus in a referenced subsystem in simulink and would like to use the bus datatype again in a different model. For this i would like to export the datatype from simulink to a dataDictionary. I tried to open the referenced subsystem in a model and use the commands Simulink.Bus.createObject and Simulink.Bus.save. But i was not able to generate the object in matlab to save it afterwards. Is there a easier solution to this?
  댓글 수: 9
Fangjun Jiang
Fangjun Jiang 2024년 5월 13일
That is weird. No more advice other than trying on the real model. Maybe contact the Mathworks tech support.
Lukas
Lukas 2024년 5월 13일
I check again, maybee its just a setting i forgot. If i find my error, i will update the forum.

댓글을 달려면 로그인하십시오.

답변 (1개)

Yatharth
Yatharth 2024년 5월 22일
Hi Lukas,
In your given code :
mdl = "BusHierarchy";
block = "BusHierarchy/Bus Creator1";
load_system(mdl)
busInfo = Simulink.Bus.createObject(mdl,block);
file1 = "DefaultFunction";
Simulink.Bus.save(file1); -> This command lead to an default matlab file without any content of the Bus Creator1
I am not able to figure out what is your referenced sub-system?
I will share my process and code for your reference:
1. Opening a Bus Object creation example
openExample('simulink/CreateSimulinkBusObjectFromBlockExample')
2. Modifying the BusObjectCreationModel.slx : I selected everything and right clicked to make a Subsystem named SS1
3. Modifying the CreateSimulinkBusObjectFromBlockExample.mlx file:
open_system('BusObjectCreationModel')
%Create a Bus object that corresponds with the bus created by the Bus Creator block.
busInfo = Simulink.Bus.createObject('BusObjectCreationModel','BusObjectCreationModel/SS1/Bus Creator'); %here I have added SS1 in the block path
Simulink.Bus.save('BusObjectFunctionCellFormat'); % here I have added the bus.save function to generate the BusObjectCreationModel.slx
Here is the documentation for the Simulink.Bus.save https://www.mathworks.com/help/simulink/slref/simulink.bus.save.html

카테고리

Help CenterFile Exchange에서 Interactive Model Editing에 대해 자세히 알아보기

제품


릴리스

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by