how can I array the external inputs for code generation in Simulink embedded coder?
12 views (last 30 days)
Show older comments
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 Comments
Accepted Answer
More Answers (1)
Fangjun Jiang
on 4 Mar 2025
Edited: Fangjun Jiang
on 4 Mar 2025
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 Comments
See Also
Categories
Find more on Configure Simulation Conditions in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!