How to assign value from a struct to a bus

5 Ansichten (letzte 30 Tage)
Nicolò Binda
Nicolò Binda am 24 Apr. 2020
Bearbeitet: Divyajyoti Nayak am 4 Mär. 2025
Hi
I've got a complex struct with different values in Matlab (a car with different components and for each of the a lot of parameters as MTTR, MTTI ecc), i generate a bus with the exact same form (i generated it form the structure, so it's exactly the same).
When i generate an entity in simulink (the entity rappresent my car) i choose "bus" as "Entity" type and i assign the bus i created as "Entity type name".
My problem now is that the entity is rappresented by the bus but there aren't value in the bus and i need to copy all this value from the struct in Matlab.
There is a way (a block or so) to automatically import all the numbers contained in the struct?
for example ai have:
car.door.MTTR=50;
when i generate the bus the value 50 is lost, so in simulink i need to reasign it
many thanks
Nicolò

Antworten (1)

Divyajyoti Nayak
Divyajyoti Nayak am 4 Mär. 2025
Bearbeitet: Divyajyoti Nayak am 4 Mär. 2025
To create a bus object from a MATLAB structure, you can make use of the 'createObject' function of the 'Simulink.Bus' object. Here's the documentation for it:
Hope this is what you were looking for.

Kategorien

Mehr zu Discrete-Event Simulation finden Sie in Help Center und File Exchange

Produkte


Version

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by