Modifying parameters for S-function in a model which is compiled / run in rapid accelerator mode
4 ビュー (過去 30 日間)
古いコメントを表示
I have a model which includes an S-function block. The model has all the necessary parameter on the model workspace. A function calls the model and runs it with different parameter sets, which works just fine in normal simulation mode, the parameters influence the initial state of the S-function .
However I want to create an exe from the model, so I'm using configureForDeployment before running the simulation. The problem is that in this case the initial state of my S-function is always the same, which refers to the values of the parameters available on the model workspace during building the rapid accelerator target. Same thing happens when I use mcc. Parameters for other blocks get updated normally.
My code is similar to (inside a for cycle):
in = Simulink.SimulationInput('MyModel');
in = in.setVariable('MyParam', MyParam, 'Workspace', in.ModelName);
in = simulink.compiler.configureForDeployment(in);
simRes = sim( in );
How can I modify the S-function parameters between simulation runs in a compiled model / in rapid accelerator mode? Thanks for the help!
0 件のコメント
回答 (1 件)
Fangjun Jiang
2020 年 9 月 11 日
Before the configureForDeployment line, use set_param('S_Function_Block','Param_Name','Param_Value') to change the parameter for the S-function block. This might make the model dirty (the model has been modified) so you might also have to save the model before you can run configureForDeployment.
3 件のコメント
Fangjun Jiang
2020 年 9 月 14 日
- It depends on the parameter data type to use 'Param_Value' or MySFunParameterValues
- The model needs to be re-build after setting the S-Function parameters, which is said in your original question. Why did you comment above that "the model is already built"?
- You might also need to run the callback functions of the S-function after you change the S-function parameters. It depends on your S-function.
参考
カテゴリ
Help Center および File Exchange で Deploy Standalone Applications についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!