![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/292885/image.jpeg)
How to access structure variables defined in c files for simulink models
조회 수: 7 (최근 30일)
이전 댓글 표시
I am having interface defenitions in c files as structure shown below and I would like to know how to access the structure variable individually inside the matlab simulink (Matlab function)?
typedef struct {
double a;
double b;
} POS;
댓글 수: 0
답변 (1개)
rajat aggarwal
2020년 5월 14일
In order to access the fields stored within the structure, you can dot-index into the object, but there is difference in how you index into the object from Simulink blocks and the MATLAB command prompt.
From a Simulink block (like Gain) you can access the structure field by indexing into the Simulink object itself.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/292885/image.jpeg)
From the MATLAB command prompt, you would need to index into the 'Value' field of the object first:
>> test.Value.a
If you intend to modify the value of the field, you can achieve this using the MATLAB command prompt
>> test.Value.a = 10;
I have also included a link to the Simulink.Parameter object description below
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Simulink Functions에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!