How to write into the memory locations of the paramater using C api?

1 回表示 (過去 30 日間)
Sahana B S
Sahana B S 2017 年 1 月 12 日
回答済み: Jordan Ross 2017 年 1 月 23 日
Hi, I am working on developing a wireless bridge for ECU communication using simulink code gereration, there are few parameters which needs to be given by the user during run time using keyboard before invoking the actual model. I have generated C api for my model to access the addresses of the paramaters along with the generated c code. But I dont know how to develop program to write into these memory locations of the paramater using C api. Can any one please tell me how I can use matlab generated C api to develop my front end application code to write values into the parameter's memory locations in real-time. Thanks in advance!

回答 (1 件)

Jordan Ross
Jordan Ross 2017 年 1 月 23 日
Hello Sahana,
As I understand, you have some parameters that need to be defined before you run the model. Instead of writing to the memory locations as your are talking about you can just set the parameters to be "Tunable " in the codegen settings. You can do this by doing the following:
  1. Assign a MATLAB variable or Simulink.Parameter as the parameter to the blocks that you want to tune.
  2. In the Configuration Parameters make sure the parameter "Default parameter behavior" is set to "Tunable".
  3. Then, in the generated code you should see a structure with the tunable parameters defined in the header file. You can then set the members of that structure to have the input values given at the command line.

カテゴリ

Help Center および File ExchangeSimulink Coder についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by