Non-static tunable parameters in C++ class code generation.
Mostrar comentarios más antiguos
Hello,
I use Simulink Coder and Embedded Coder to auto-generate a C++ class from a Simulink model. The Simulink model contains only Simulink function blocks (Simulink/User-Defined Functions/Simulink Function) on the root level. The C++ class is instantiated several times from a C++ wrapper and its functions (Simulink function blocks) are called. A parameter structure with a bus data type in the base workspace is used to parametrize the Simulink function blocks. The storage class of the parameter structure is set to Model default.
The code generation uses the following settings:
- Code interface packaging: C++ class
- Parameter visibility: public
In MATLAB R2018b the generated C++ class contains:
// Class declaration for model Test
class TestModelClass {
// public data and function members
public:
// Tunable parameters
P_Test_t Test_P;
In MATLAB R2019a the generated C++ class contains:
// Class declaration for model Test
class TestModelClass {
// public data and function members
public:
// Tunable parameters
static P_Test_t Test_P;
The only difference is the static keyword for the tunable parameters.
As a result, I cannot change the tunable parameters for a single instance, since the parameters are declared as static and, therefore, shared across all instances. Is there a possibility to avoid the static keyword or should I use a different approach in MATLAB R2019a?
Thx for helping...
8 comentarios
db1024
el 10 de Mayo de 2019
db1024
el 6 de Abr. de 2020
db1024
el 6 de Abr. de 2020
Carlos Ma
el 3 de Jul. de 2020
@db1024 Hey man I came across the same problem too. Have you found a solution yet?
db1024
el 3 de Jul. de 2020
Carlos Ma
el 3 de Jul. de 2020
@db1024 thanks mate
can't believe this feature didn't come by default
db1024
el 15 de Oct. de 2020
db1024
el 15 de Oct. de 2020
Respuestas (1)
David Balbuena
el 26 de Jul. de 2023
0 votos
Generating non-static parameters is supported starting in R2021a. See this post for instructions on how to configure the model: https://www.mathworks.com/matlabcentral/answers/461376-does-embedded-coder-support-instance-specific-parameters-for-top-model-when-generating-c-code
Categorías
Más información sobre Simulink Coder en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!