how can I array the external inputs for code generation in Simulink embedded coder?
3 ビュー (過去 30 日間)
古いコメントを表示
I am building the c-code of a Subsystem in Simulink with the embedded coder. The created header file includes the following code-snippet which represents the 6 inports and 2 outports of the subsystem.
/* External inputs (root inport signals with default storage) */
typedef struct {
real_T V_dc_abs_B; /* '<Root>/V_dc_abs_B' */
real_T CM_B; /* '<Root>/CM_B' */
real_T GMEAS_A; /* '<Root>/GMEAS_A' */
} ExtU_Regelung_T;
/* External outputs (root outports fed by signals with default storage) */
typedef struct {
real_T AO_A; /* '<Root>/AO_A' */
real_T AO_B; /* '<Root>/AO_B' */
} ExtY_Regelung_T;
I also got an example code of a different simulink model which I'm following (I don't have the actual model, only the code). In their code, the external inputs and outputs code-snippet look like this:
/* External inputs (root inport signals with default storage) */
typedef struct {
real_T INPUTS[24]; /* '<Root>/INPUTS' */
} ExtU_WindExample_T;
/* External outputs (root outports fed by signals with default storage) */
typedef struct {
real_T OUTPUTS[21]; /* '<Root>/OUTPUTS' */
} ExtY_WindExample_T;
I would like to change my simulink model in a way that the embedded coder generates my external inputs and outputs the same way as in the example - as an array.
I have no idea which blocks to use for this problem and would much appreciate any help. I already tried to use bus creator and selector, but it didn't give me the desired result.
0 件のコメント
採用された回答
その他の回答 (1 件)
Fangjun Jiang
2025 年 3 月 4 日
編集済み: Fangjun Jiang
2025 年 3 月 4 日
For the array case, you just need to specify the size of that Inport block. Keep in mind that you can't comibne multiple inputs into one array if the data types are different.
The bus signal will be mapped to a strucutre in C code by the code generation.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Configure Simulation Conditions についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
