Simulink Custom Storage Class "Importeddefine"
조회 수: 7 (최근 30일)
이전 댓글 표시
I have a headerfile (params.h) with some defines (#define test_param 22) and want to use/import this in a Simulink model (ERTW). I add a Simulink.Parameter and assign "ImportedDefine (Custom)" as Storage Class and add "params.h" to the "Custom attributes -> Header file". How can I use this "test_param" in the model (it does not work with a constant / gain block) ?
댓글 수: 2
Kaustubha Govind
2011년 1월 28일
Hi Andreas,
Do you see an error when you use the parameter with a gain block? Could you post the error?
~K
답변 (1개)
MarkB
2011년 1월 31일
Basically, Simulink itself doesn't use header files, but compilers do. Thus, in this case the "Simulink.Parameter"'s job is essentially to describe the content of the header file for simulation. As a result, the ".Value" field that you use in your "Simulink.Parameter" object is the number that Simulink will use when you press the "play" button.
However, when you generate code, the data object will cause a "#include" statement to appear in the generated code, and the code will use (but not define or declare) the name "test_param", expecting the header file provide it.
Since the "Simulink.Parameter" is what is used for simulation, it is important to ensure that it accurately reflects what the header file will provide to the generated code (i.e. the numeric values should match).
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!