How to input bus data (values) into my simulink model?
8 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
So I have an inport that expects a bus signal. This bus signal is a "struct/bus object" which I have defined from a data dictionary.
Now what I need to do is to not only define/declare it (speaking like using the programming language C), but also create a variable from that "data type"/struct.
That struct then needs to be filled with actual values, so I can pass the values into the Simulink model. The values shall be generated by MATLAB.
So my actual question is:
- How can I create a Bus/struct (that was defined in Simulink/Data dictionary) variable in MATLAB, fill it with values, and pass it into Simulink, so I can make simulations with it?
It does not seem like I can create a bus object from my defined Bus object (from my data dictionary). So how do I create a "Bus-Struct/Object" in MATLAB? Then, how do I fill the member variables of that Bus/Struct? It does not look like I can access the members directly. And afterwards: I need to save it to a *.mat file and load it into my Simulink model.
So basically what I want to do is the following (using c to illustrate my point):
/* Defined in simulink/data dictionary: */
typedef struct {
int x;
struct obj y;
double z;
} myBusStruct;
/* Declare struct in MATLAB and fill it with values */
myBusStruct mbs;
mbs.z = 1.3;
mbs.x = 7;
mbs.y = /* assign plausible value */;
/* Save to mat-file and load into Inports of Simulink model */
saveToMat(mbs);
Can anyone help me?
0 comentarios
Respuestas (1)
Josh Chen
el 10 de Feb. de 2023
Hey Timo,
If you have that bus/struct saved in Data dictionary, you should be able to bring it to MATLAB with "Simulink.data.dictionary.open". After that, you can access the specific struct or create a new one based on it. This page shows you how to access data dictionary programmatically.
Hope this helps,
Josh
2 comentarios
Josh Chen
el 13 de Feb. de 2023
Hey Timo.
It is hard to explain without an example. But if you are looking for a doc page showing how to modify value for a Simulink.Bus, you can check this one.
Josh
Ver también
Categorías
Más información sobre Dependency Analysis en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!