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!