How do I make an S-Function run-time parameter instance-specific inside a model reference?

14 vues (au cours des 30 derniers jours)

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?

Réponse acceptée

MathWorks Support Team
MathWorks Support Team le 19 Mar 2024
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:

Plus de réponses (0)

Tags

Aucun tag saisi pour le moment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by