MATLAB Answers

Does Embedded Coder support instance-specific parameters for top model when generating C++ code?

4 views (last 30 days)
I am using tunable Simulink.Parameter in R2019a, which has a "Model default" storage class. In R2019a, the generated code of this tunable parameter has the keyword "static", it is declared as static class members. Thus, these "tunable parameters" are no longer linked to a particular instance. I expected the "Tunable parameters" links to a certain instance in the generated code.
In R2018b, with the same setting, you will not get "static" for it.
What causes this change? And how can I generate code for tunable parameters without "static"?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 6 Dec 2019
Edited: MathWorks Support Team on 6 Dec 2019
After discussing the issue with our developers, we came to the conclusion: essentially, the R2018b behavior was a bug. R2019a fixed the issue.
With the keyword "static", tunable parameters are declared as static class members. A static member has only one memory location for any number of instances for the class. So, the R2019a behavior is the intended behavior.
In general, parameters defined by workspace variables are shared across all instances of models / code, and Model Default for Simulink.Parameter should result in a shared parameter.
There is no way to generate instance-specific parameters for top model C++ code generation in R2019a. However, our developers would like to add support for instance-specific parameters for top model code generation in a future release.

  1 Comment

db1024
db1024 on 25 Oct 2019
Is the mentioned support for instance-specific parameters for top model code generation in a future MATLAB release already added to R2019b?
I could not find any hint in the release notes...

Sign in to comment.

More Answers (0)

Sign in to answer this question.