Is it possible in SimEvents to define entity attributes using a MATLAB script?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Timothy
am 5 Jun. 2024
Beantwortet: Laurent Royer
am 7 Jun. 2024
Is it possible in SimEvents to define entity attributes using a MATLAB script?
I know how to define attributes manually in the Entity type tab of the Entity Generator block. I also know how to write MATLAB code in the Event actions tab to change the value of previously defined attribute. I want to use a MATLAB script to define the attributes so that I can skip the manual process of defining attributes and setting their initial values each time I use a new Entity Generator block.
Thank you.
0 Kommentare
Akzeptierte Antwort
Laurent Royer
am 7 Jun. 2024
I see several ways to achieve this.
1. You could store your Entity Generator block with the required Enty Type definition in a Simulink library. So each time you pick the block from the library, it is already configured as expected.
2. With a script, you could find all existing Entity Generator blocks in your current model and modify all Entity Type definitions:
blocks = string(find_system(bdroot, "BlockType", "EntityGenerator"));
for idx = 1:numel(blocks)
set_param(blocks(idx), ...
"EntityType", "Structured", ...
"AttributeName", "data1|data2|data3", ...
"AttributeInitialValue", "1|2|3");
end
3. You could use a Bus object to store the Entity type. However it doesn't allow to define a non-zero initial value, and you still have to use an event action to set the initial value (can also be done by script though).
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Discrete-Event Simulation 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!