MATLAB Answers

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

1 view (last 30 days)
Sahana B S
Sahana B S on 12 Jan 2017
Answered: Jordan Ross on 23 Jan 2017
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!

  0 Comments

Sign in to comment.

Answers (1)

Jordan Ross
Jordan Ross on 23 Jan 2017
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.

  0 Comments

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!

Translated by