How to call C custom variable or constant in Simulink Model
조회 수: 9 (최근 30일)
이전 댓글 표시
Good evening,
I'm looking for a method to call a variable or constant defined in a custom C code inside a simulink model.
I already use several functions with C Caller both in the model and in Stateflow.
Can someone help me?
댓글 수: 0
답변 (1개)
Mark McBroom
2020년 5월 4일
not sure what you mean by "call", but one solution would be to put the variable inside a C function that simply returns the constant. Then use C Caller block to call this new C function.
Thanks.
Mark.
댓글 수: 2
Mark McBroom
2020년 5월 4일
If you want to hvae the external C file declare and define the variable, you can have the generated code use that external definition. This can be done by creating a Simulink.Parameter data object, and then setting it's storage class to be "Imported Extern". This will allow you to use the constant in Simulink, but the declaration and definition are done in an external, hand written C file.
This link to the doc gives more details:
Thanks.
Mark.
참고 항목
카테고리
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!