Tuning parameters via C API
Show older comments
I have created tunable parameters in my Simulink model and have compiled it using the grt. Now I would like to change the value of these parameters via an external interface. What is the function call to do this? How do I hook into the dll?
Answers (1)
Kaustubha Govind
on 19 Oct 2011
0 votes
You should find a parameter structure declared as "extern" in the modelname.h file. It typically has a type named something like Parameters_modelname and a variable named modelname_P, and is defined in the modelname_data.c file. You can eliminate this definition and create your own. Since this is a global variable, you can access in from anywhere in code and modify it.
You can also customize what the tunable parameter data structure looks like by choosing a different Tunable Parameter Storage Class.
This page explains how you can create your parameter as a Simulink.Parameter object and choose a storage class.
1 Comment
vcmorini
on 17 Jul 2017
Hello Kaustubha Govind, could you provide an example about changing parameters values with C API ?
It works for Simscape and Simulink?
C API is the only way to change tunable parameters values after code generation? Because I was looking at Generating Code Multibody and does not says anything about C API.
Thank you
Categories
Find more on Run-Time Parameters in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!