Tunable parameters in Simulink code generation
조회 수: 9 (최근 30일)
이전 댓글 표시
I am making an S-Function with mask parameters and want to generate C code for this block. All S-Function parameters should be tunable. Currently I declared the parameters as tunable via ssSetSFcnParamTunable(S, PARAM_P0_IDX, SS_PRM_TUNABLE); and ssRegAllTunableParamsAsRunTimeParams. I also verified that the parameters show up in the model.rtw file. However, in code generation the parameters are still inlined (i.e., I see 1.0f instead of myDataStruct.myParam).
I tried the sfcndemo_runtime example and see the same behavior. Only when the mask parameters are declared in the base workspace, they become tunable. The S-Function I am making will be used in a library block and I expect there to be multiple instances of this block. Therefore declaring the workspace variables automatically will be error-prone. The generated code will not be functional when (some) parameters are inlined, and I don't want to make the user responsible for declaring these workspace variables.
Is there a way to get tunable parameters in the generated code without declaring corresponding variables in the base workspace?
댓글 수: 0
답변 (1개)
Akshat Dalal
2024년 10월 7일
Hi,
You can declare the variales in Model Workspace of the library block. This way, it will be distinct for each instance of the block. You can have a look the following docuementation for more information: https://www.mathworks.com/help/rtw/ug/configure-data-accessibility-for-rapid-prototyping.html
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!