Simulink coder and naming of initial condition load variable

1 回表示 (過去 30 日間)
Nicolas B
Nicolas B 2025 年 2 月 21 日
コメント済み: Nicolas B 2025 年 2 月 21 日
Hi,
I am generating code from Simulink and when I use the enabled subsystem, sometimes, I set "states when enabling" to reset. That's a convenient way to reset all states in the subsystem without creating a signal for that and works very well. Btw, I am also using that with the if statement "architecture".
There is only 1 "small difficulty" I have. In the generated code, I get 1 variable named "icload_xyz" per state I have in the subsystem. So if I have for example 3 delay blocks, I will have "icload_a", "icload_b" and "icload_c" added to the generated code.
Does someone with experience knows how to:
  1. define the same of these variables.
  2. have 1 variable per enabled subsystem (or if subsystem).
Thank you for your help.
Regards, Nicolas
  2 件のコメント
Fangjun Jiang
Fangjun Jiang 2025 年 2 月 21 日
If you have three states then you need to have three varialbes, right?
If not, can you explain how it can be done if you write C code yourself?
Nicolas B
Nicolas B 2025 年 2 月 21 日
Only if you can initialize separately the 3 states.
For example, in C:
bool isload = false;
int8 myState1 = 0;
int8 myState2 = 0;
if(isload == false){
myState1 = 1;
myState2 = 2;
isload = true;
}
/* my code... */

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

回答 (0 件)

カテゴリ

Help Center および File ExchangeSimulink Coder についてさらに検索

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by