How to input bus data (values) into my simulink model?
조회 수: 8 (최근 30일)
이전 댓글 표시
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
답변 (1개)
Josh Chen
2023년 2월 10일
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
Josh Chen
2023년 2월 13일
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
참고 항목
카테고리
Help Center 및 File Exchange에서 Dependency Analysis에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!