
How do I make an S-Function run-time parameter instance-specific inside a model reference?
16 ビュー (過去 30 日間)
古いコメントを表示
MathWorks Support Team
2024 年 3 月 19 日
回答済み: MathWorks Support Team
2024 年 3 月 19 日
I have an S-Function with run-time parameters defined using the workflow here: https://www.mathworks.com/help/simulink/sfg/run-time-parameters-cpp.html
How can I promote that run-time parameter to be a Model Argument?
採用された回答
MathWorks Support Team
2024 年 3 月 19 日
You first need to set the "transformed" field of the ssParamRec struct to RTPARAM_MAKE_TRANSFORMED_TUNABLE. Then you can create a Model Workspace parameter marked as argument, and you use that parameter in place of the dialog parameter that is bound to your runtime parameter:

This makes the connection between the instance-specific parameter in the Model Workspace, and the run-time parameter you defined in your S-Function.
A working example is attached. The S-Function is in scalar_param_sfun.c and it uses a dialog parameter and defines a run-time parameter derived from that dialog parameter. In the S-Function code you will see a run-time parameter definition like this:
/* Configure run-time parameter information */
p.name = "myParam";
p.nDimensions = 2;
p.dimensions = myParamDims;
p.dataTypeId = RUN_TIME_DATA_TYPE;
p.complexSignal = COMPLEX_NO;
p.data = myParam;
p.dataAttributes = NULL;
p.nDlgParamIndices = 1; //only derive from the first dialog parameter
p.dlgParamIndices = &dlg;
p.transformed = RTPARAM_MAKE_TRANSFORMED_TUNABLE; //This is required to tune the parameter inside a model reference
p.outputAsMatrix = false;
For more information, see:
0 件のコメント
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!