The following procedure shows you how to define or edit double
, single
, int64
, int32
, int16
, int8
, uint64
, uint32
, uint16
, uint8
, logical
,
and char
types.
For more information about defining other types, see the information in this table.
Input Type | Link |
---|---|
A string scalar (1-by-1 string array) | Specify a String Scalar Input Parameter |
A structure (struct) | Specify a Structure Input Parameter |
A cell array (cell (Homogeneous) or cell (Heterogeneous)) | Specify a Cell Array Input Parameter |
A fixed-point data type (embedded.fi) | Specify a Fixed-Point Input Parameter |
An input by example (Define by Example) | Define Input Parameter by Example by Using the App |
A constant (Define Constant) | Define Constant Input Parameters Using the App |
Click the field to the right of the input parameter name.
Optionally, for numeric types, to make the parameter a complex type, select the Complex number check box.
Select the input type.
The app displays the selected type. It displays and the size options.
From the list, select whether your input is a scalar,
a 1 x n
vector, a m x 1
vector,
or a m x n
matrix. By default, if you do not select
a size option, the app defines inputs as scalars.
Optionally, if your input is not scalar, enter sizes m
and n
.
You can specify:
Fixed size, for example, 10
.
Variable size, up to a specified limit, by using the :
prefix.
For example, to specify that your input can vary in size up to 10
,
enter :10
.
Unbounded variable size by entering :Inf
.
You can edit the size of each dimension.
To specify that an input is a string scalar:
On the Define Input Types page, click Let me enter input or global types directly.
Click the field to the right of the input parameter that you want to define.
Select string. Then select 1x1
scalar
.
The type is a 1-by-1 string array (string scalar) that contains a character vector.
To specify the size of the character vector, click the field to the right of
the string array element {1}
. Select
char. Then, select 1xn vector
and enter the size.
To make the string variable-size, click the second dimension.
To specify that the second dimension is unbounded, select
:Inf
.
To specify that the second dimension has an upper bound, enter the
upper bound, for example 8
. Then, select
:8
.
To specify that an input uses the enumerated type MyColors
:
Suppose that the enumeration MyColors
is
on the MATLAB® path.
classdef MyColors < int32 enumeration green(1), red(2), end end
On the Define Input Types page, click Let me enter input or global types directly.
In the field to the right of the input parameter,
enter MyColors
.
To specify fixed-point inputs, Fixed-Point Designer™ software must be installed.
On the Define Input Types page, click Let me enter input or global types directly.
Click the field to the right of the input parameter that you want to define.
Select embedded.fi.
Select the size. If you do not specify the size, the
size defaults to 1x1
.
Specify the input parameter numerictype
and fimath
properties.
If you do not specify a local fimath, the app uses the default fimath. See Default fimath Usage to Share Arithmetic Rules (Fixed-Point Designer).
To modify the numerictype
or fimath
properties, open the properties
dialog box. To open the properties dialog box, click to the right
of the fixed-point type definition. Optionally, click .
When a primary input is a structure, the app treats each field as a separate input. Therefore, you must specify properties for all fields of a primary structure input in the order that they appear in the structure definition:
For each field of an input structure, specify class, size, and complexity.
For each field that is a fixed-point class, also specify numerictype, and fimath.
On the Define Input Types page, click Let me enter input or global types directly.
Click the field to the right of the input parameter that you want to define.
Select struct.
The app displays the selected type, struct
.
The app displays the size options.
Specify that your structure is a scalar, 1
x n
vector, m x 1
vector, or m
x n
matrix. By default, if you do not select a size option,
the app defines inputs as scalars.
If your input is not scalar, enter sizes for each
dimension. Click the dimension. Enter the size. Select from the size
options. For example, for size 10
:
To specify fixed size, select 10
.
To specify variable size with an upper bound of 10
,
select :10
.
To specify unbounded variable size, select :Inf
.
Optionally, specify properties for the structure in the generated code. See Set Structure Properties.
Add fields to the structure. Specify the class, size, and complexity of the fields. See Add a Field to a Structure.
Click to the right of the structure definition. Optionally, click .
In the dialog box, specify properties for the structure in the generated code.
Property | Description |
---|---|
C type definition name | Name for the structure type in the generated code. |
Type definition is externally defined | Default: If
you select Dependency: |
C type definition header file | Name of the header file that contains the external definition
of the structure, for example, By
default, the generated code contains Dependency:
When |
Data alignment boundary | The run-time memory alignment of structures of this type in bytes. If you have an Embedded Coder® license and use Code Replacement Libraries (CRLs), the CRLs provide the ability to align data objects passed into a replacement function to a specified boundary. You can take advantage of target-specific function implementations that require aligned data. By default, the structure is not aligned on any specific boundary so it is not matched by CRL functions that require alignment. Alignment
must be either Default: Dependency:
When |
Select the name field of the structure that you want to rename. Enter the new name.
To the right of the structure, click
Enter the field name. Specify the class, size, and complexity of the field.
Select the structure field below which you want to add another field.
Right-click the structure field.
Select Insert Field Below.
The app adds the field after the field that you selected.
Enter the field name. Specify the class, size, and complexity of the field.
Right-click the field that you want to remove.
Select Remove Field.
For code generation, cell arrays are homogeneous or heterogeneous. See Code Generation for Cell Arrays. A homogeneous cell array is represented as an array in the generated code. All elements have the same properties. A heterogeneous cell array is represented as a structure in the generated code. Elements can have different properties.
On the Define Input Types page, click Let me enter input or global types directly.
Click the field to the right of the input parameter that you want to define.
Select cell (Homogeneous).
The app displays the selected type, cell
.
The app displays the size options.
From the list, select whether your input is a scalar,
a 1 x n
vector, a m x 1
vector,
or a m x n
matrix. By default, if you do not select
a size option, the app defines inputs as scalars.
If your input is not scalar, enter sizes for each
dimension. Click the dimension. Enter the size. Select from the size
options. For example, for size 10
:
To specify fixed size, select 10
.
To specify variable size with an upper bound of 10
,
select :10
.
To specify unbounded variable size, select :Inf
.
Below the cell array variable, a colon inside curly braces {:}
indicates
that the cell array elements have the same properties (class, size,
and complexity).
To specify the class, size, and complexity of the
elements in the cell array, click the field to the right of {:}
.
On the Define Input Types page, click Let me enter input or global types directly.
Click the field to the right of the input parameter that you want to define.
Select cell (Heterogeneous).
The app displays the selected type, cell
.
The app displays the size options.
Specify that your structure is a scalar, 1
x n
vector, m x 1
vector, or m
x n
matrix. By default, if you do not select a size option,
the app defines inputs as scalars.
Optionally, if your input is not scalar, enter sizes m
and n
.
A heterogeneous cell array is fixed size.
The app lists the cell array elements. It uses indexing notation
to specify each element. For example, {1,2}
indicates
the element in row 1, column 2.
Specify the class, size, and complexity for each cell array element.
Optionally, add elements. See Add an Element to a Heterogeneous Cell Array
Optionally, specify properties for the structure that represents the cell array in the generated code. See Set Structure Properties for a Heterogeneous Cell Array.
A heterogeneous cell array is represented as a structure in the generated code. You can specify the properties for the structure that represents the cell array.
Click to the right of the cell array definition. Optionally click .
In the dialog box, specify properties for the structure in the generated code.
Property | Description |
---|---|
C type definition name | Name for the structure type in the generated code. |
Type definition is externally defined | Default: If
you select Dependency: |
C type definition header file | Name of the header file that contains the external definition
of the structure, for example, By
default, the generated code contains Dependency:
When |
Data alignment boundary | The run-time memory alignment of structures of this type in bytes. If you have an Embedded Coder license and use Code Replacement Libraries (CRLs), the CRLs provide the ability to align data objects passed into a replacement function to a specified boundary. You can take advantage of target-specific function implementations that require aligned data. By default, the structure is not aligned on any specific boundary so it is not matched by CRL functions that require alignment. Alignment
must be either Default: Dependency:
When |
To change the classification as homogeneous or heterogeneous, right-click the variable. Select Homogeneous or Heterogeneous.
The app clears the definitions of the elements.
In the definition of the cell array, click a dimension. Specify the size.
For a homogeneous cell array, specify whether the dimension is variable size and whether the dimension is bounded or unbounded. Alternatively, right-click the variable. Select Bounded (fixed-size), Bounded (variable-size), or Unbounded
For a heterogeneous cell array, the app adds elements so that the cell array has the specified size and shape.
In the definition of the cell array, click a dimension. Specify the size. For example, enter 1 for the first dimension and 4 for the second dimension.
The app adds elements so that the cell array has the specified
size and shape. For example for a 1x4 heterogeneous cell array, the
app lists four elements: {1,1}
, {1,2}
, {1,3}
,
and {1,4}
.
Specify the properties of the new elements.