Main Content

Dynamic array container type

Container type for dynamic arrays

Since R2024b

Model Configuration Pane: Code Generation / Code Style

Description

Specify a container type for dynamic arrays in the generated code. Choose either coder::array or std::vector.

Dependencies

  • To enable this parameter, set the Language model configuration parameter to C++.

Settings

std::vector (default) | coder::array

Default: std::vector

std::vector

The code generator generates std::vector containers to represent dynamic arrays.

coder::array

The code generator generates coder::array containers to represent dynamic arrays. If you open a model that was created before R2024b, the model defaults to this setting.

Examples

expand all

Consider this model, myModel:

Model that passes an unbounded variable-size signal from an Inport block to an Outport block.

The model passes an unbounded variable-size 1-dimensional signal from an Inport block to an Outport block. If you set the Dynamic array container type model configuration parameter to std::vector, the code generator produces this code in myModel.h:

// External inputs (root inport signals with default storage)
struct ExtU_myModel_T {
  std::vector<real_T> Input;         // '<Root>/Input'
};

// External outputs (root outports fed by signals with default storage)
struct ExtY_myModel_T {
  std::vector<real_T> Out1;          // '<Root>/Out1'
};
If you set the Dynamic array container type model configuration parameter to coder::array, the code generator produces this code instead:
// External inputs (root inport signals with default storage)
struct ExtU_myModel_T {
  coder::array<real_T,1> Input;      // '<Root>/Input'
};

// External outputs (root outports fed by signals with default storage)
struct ExtY_myModel_T {
  coder::array<real_T,1> Out1;       // '<Root>/Out1'
};

Recommended Settings

ApplicationSetting
DebuggingNo impact
TraceabilityNo impact
EfficiencyNo impact
Safety precautionNo recommendation

Programmatic Use

Parameter: DynamicArrayContainerType
Type: character vector
Values: 'std::vector' |'coder::array'
Default: 'std::vector'

Version History

Introduced in R2024b