Dynamic array container type - Container type for dynamic arrays - MATLAB (original) (raw)
Main Content
Container type for dynamic arrays
Since R2024b
Model Configuration Pane: Code Generation / Code Style
Description
Specify a container type for 1-dimensional dynamic arrays in the generated code. Choose either coder::array
or std::vector
.
This parameter affects only 1-dimensional dynamic arrays. For higher-dimensional dynamic arrays, the code generator generates coder::array
containers regardless of the value of this parameter.
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 1-dimensional dynamic arrays.
coder::array
The code generator generates coder::array
containers to represent 1-dimensional dynamic arrays. If you open a model that was created before R2024b, the model defaults to this setting.
Examples
Consider this model, myModel
:
The model passes an unbounded variable-size 1-dimensional signal from anInport block to an Outport block. If you set theDynamic array container type model configuration parameter to std::vector
, the code generator produces this code inmyModel.h
:
// External inputs (root inport signals with default storage) struct ExtU_myModel_T { std::vector Input; // '/Input' };
// External outputs (root outports fed by signals with default storage) struct ExtY_myModel_T { std::vector Out1; // '/Out1' };
If you set the Dynamic array container type model configuration parameter tocoder::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; // '/Input' };
// External outputs (root outports fed by signals with default storage) struct ExtY_myModel_T { coder::array<real_T,1> Out1; // '/Out1' };
Recommended Settings
Application | Setting |
---|---|
Debugging | No impact |
Traceability | No impact |
Efficiency | No impact |
Safety precaution | No recommendation |
Programmatic Use
Parameter: DynamicArrayContainerType |
---|
Type: character vector |
Values: 'std::vector' |'coder::array' |
Default: 'std::vector' |
Version History
Introduced in R2024b