Problem to change parameter value in SFunction

1 view (last 30 days)
Hello,
I have a simple SFunction with 3 inputs, 2 outputs and 11 parameters (p1 to p11). I generate this SFunction with the S-function builder block.
I need to initiliaze parameters p10 and p11 in mdlstart so for this I do the following:
real_T *p10 = (real_T*)mxGetData(PARAM_DEF9(S));
real_T *p11 = (real_T*)mxGetData(PARAM_DEF10(S));
p10[0] = 1234;
p11[0] = 5678;
Then I want to connect these parameters to my output in the Outputs_wrapper function. To do this I try the following:
y0[0] = p10[0];
y1[0] = p11[0];
This is function in Simulink but not when I compil my model and set it into VeriStand, but if I try to do this with my two first parameters this is work (change p10 by p1 and p11 by p2 and PARAM_DEF9 by PARAM_DEF0 et PARAM_DEF10 by PARAM_DEF1).

Accepted Answer

Julien
Julien on 3 Dec 2014
I solved my issue. Simulink need that a Workspace variable was set in the mask of the SFunction. p1, p2, ... permit to access to this workspace variable and modify its value but they are not variable itself. So I declare a new workspace variable (in example test) and I set it in the mask of the SFunction for p11 and I'm able to change the value of p11 in mdlStart function and in output_wrapper function.

More Answers (0)

Categories

Find more on Block and Blockset Authoring in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!