Non-static tunable parameters in C++ class code generation.

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 件のコメント

db1024
db1024 2019 年 5 月 10 日
Would it be possible to use a custom storage class for this purpose?
db1024
db1024 2020 年 4 月 6 日
I updated the release of this question to R2020a, since the issue exists in R2019a, R2019b, and R2020a.
db1024
db1024 2020 年 4 月 6 日
Carlos Ma
Carlos Ma 2020 年 7 月 3 日
@db1024 Hey man I came across the same problem too. Have you found a solution yet?
db1024
db1024 2020 年 7 月 3 日
Not yet, but MathWorks told me that the possibility for non-static tunable parameters will be implemented in an upcoming release.
Carlos Ma
Carlos Ma 2020 年 7 月 3 日
@db1024 thanks mate
can't believe this feature didn't come by default
db1024
db1024 2020 年 10 月 15 日
I updated the release of this question to R2020b, since the issue exists in R2019a, R2019b, R2020a, and R2020b.
db1024
db1024 2020 年 10 月 15 日
Another question has been (re-)published about this issue by the MathWorks Support Team on 30 Jan 2020:

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeSimulink Coder についてさらに検索

製品

リリース

R2020b

質問済み:

2019 年 5 月 7 日

回答済み:

2023 年 7 月 26 日

Community Treasure Hunt

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

Start Hunting!

Translated by