![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/174736/image.png)
How can i create bus elements of one bus object from code in simulink?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Gabriela
am 6 Apr. 2014
Kommentiert: Gabriela
am 7 Apr. 2014
How can i create bus elements of one bus object from code in simulink? I mean I can create a bus object using Simulink.Bus, but i don't succeed to create its elements.
thank you
0 Kommentare
Akzeptierte Antwort
Niklas Nylén
am 7 Apr. 2014
In matlab code, create a generic element using
myElement = Simulink.BusElement;
You can set the properties of the new element by directly accessing the values. For example
myElement.Name = 'mySignal';
myElement.DataType = 'uint8';
Once you are finished with the element, you can add it to the bus:
myBus = Simulink.Bus; % You only need to do this once when you create the bus object
myBus.Elements(end+1) = myElement; % Add the element to the bus
Another way to create bus objects is to implement the bus in simulink with all its inputs with correct data types and sizes. For example like this:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/174736/image.png)
Select the bus creator block and run the following code:
Simulink.Bus.createObject(gcs, gcb);
This will put a bus object named like the output signal of the bus creator, in this case myBus, in the workspace.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Composite Interfaces finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!