MATLAB Answers

Change parameters in Simscape model executable

4 ビュー (過去 30 日間)
Antonin Berthelot
Antonin Berthelot 2020 年 1 月 7 日
編集済み: Antonin Berthelot 2020 年 1 月 15 日
I converted a Simscape model to C code and Matlab generated a .exe file as well. The idea is to deploy this model without giving access to the model content. The end-user will use Matlab to run this executable.
The executable runs and produces correct results, however I cannot figure out how to change the parameters used for the simulation.
Attached is a basic example where I would like to be able to change the value of the AC Voltage Source peak amplitude, which is currently given by a workspace variable.

  0 件のコメント

サインイン to comment.

採用された回答

Urmila Rajpurohith
Urmila Rajpurohith 2020 年 1 月 13 日
you can follow below steps to change parameters in Simscape model executable
  • In Preference -> Simscape enable "Show runtime parameter settings".
  • Ensure that you have a Simulink parameter that defines the specified Run-time parameter you want to change.
  • Set the parameter to Run-time.
  • Ensure the Simulink parameter's storage class is "Model Default".
  • Enable "Generate Example main program" in Simulink Configuration Parameters under Code Generation > Templates > Custom Templates.
  • Enable "Generate C API for Parameters" in the Configuration Parameters under Code Generation > Interface > Data Exchange Interface.
  • Generate code for the model.
You will have to edit the example main file to set the value for the parameter you want to change, but a function should be produced that looks like "rtDataAddrMap". Inside the main function before "rt_OneStep()" is called, handle the value for the tune-able parameter.

  1 件のコメント

Antonin Berthelot
Antonin Berthelot 2020 年 1 月 15 日
Thank you for your answer!
In the end, some of the parameters I wanted to change were compile-time only unfortunaly. I'm afraid I will have to wait for a Matlab update before being able to generate C code for this specific Simscape model.
However, Matlab support suggested a workaround that allows me to deploy the Simscape model without giving access to the content:
1) Group all Simscape blocks in a Subsystem
3) Generate ssc code from the subsystem.
4) Protect the ssc code.
5) Build a Simscape block from it.

サインイン to comment.

その他の回答 (0 件)

サインイン してこの質問に回答します。


Translated by