Createcoder.Type
object to represent type of an entry-point function input
Thecoder.newtype
function is an advanced function that you can use to control thecoder.Type
object. Consider usingcoder.typeof
instead ofcoder.newtype
. The functioncoder.typeof
creates a type from a MATLAB®example. By default,t
=coder.newtype
('class_name'
) does not assign any properties of the class,class_name
to the objectt
.
Note
You can also create and editcoder.Type
objects interactively by using the Coder Type Editor. SeeCreate and Edit Input Types by Using the Coder Type Editor.
creates at
= coder.newtype(numeric_class
,sz
,variable_dims
)coder.Type
object representing values of classnumeric_class
, sizessz
(upper bound), and variable dimensionsvariable_dims
. Ifsz
specifiesinf
for a dimension, then the size of the dimension is unbounded and the dimension is variable-size. Whenvariable_dims
is not specified, the dimensions of the type are fixed except for those that are unbounded. Whenvariable_dims
is a scalar, it is applied to type dimensions that are not1
or0
, which are fixed.
creates at
= coder.newtype(numeric_class
,sz
,variable_dims
,Name,Value
)coder.Type
object by using additional options specified as one or more Name, Value pair arguments.
creates at
= coder.newtype('struct',struct_fields
,sz
,variable_dims
)coder.StructType
object for an array of structures that has the same fields as the scalar structurestruct_fields
. The structure array type has the size specified bysz
and variable-size dimensions specified byvariable_dims
.
creates at
= coder.newtype('cell',cells
,sz
,variable_dims
)coder.CellType
object for a cell array that has the cells and cell types specified bycells
. The cell array type has the size specified bysz
and variable-size dimensions specified byvariable_dims
. You cannot change the number of cells or specify variable-size dimensions for a heterogeneous cell array.
creates at
= coder.newtype('embedded.fi',numerictype,sz
,variable_dims
,Name,Value
)coder.FiType
object representing a set of fixed-point values that havenumerictype
and additional options specified by one or more Name, Value pair arguments.
creates at
= coder.newtype(enum_value
,sz
,variable_dims
)coder.Type
object representing a set of enumeration values of classenum_value
.
creates at
= coder.newtype('class_name'
)coder.ClassType
object for an object of the classclass_name
. The new object does not have any properties of the classclass_name
.
creates a type for a string scalar. A string scalar contains one piece of text represented as a character vector. To specify the size of the character vector and whether the second dimension is variable-size, create a type for the character vector and assign it to thet
= coder.newtype('string')Value
property of the string scalar type. For example,t.Properties.Value = coder.newtype('char',[1 10],[0 1])
specifies that the character vector inside the string scalar is variable-size with an upper bound of 10.
For sparse matrices,coder.newtype
drops upper bounds for variable-size dimensions.
For GPU input types, only bounded numeric and logical base types are supported. Scalar GPU arrays, structures, cell-arrays, classes, enumerated types, character, half-precision and fixed-point data types are not supported.
When usingcoder.newtype
to represent GPU inputs, the memory allocation (malloc) mode property of the GPU code configuration object to'discrete'
.
Thecoder.newtype
function fixes the size of a singleton dimension unless thevariable_dims
argument explicitly specifies that the singleton dimension has a variable size.
例如,这代码指定了一个1 - 10双. The first dimension (the singleton dimension) has a fixed size. The second dimension has a variable size.
t= coder.newtype('double',[1 10],1)
t= coder.newtype('double',[1 10],[1 1])
For aMATLAB Functionblock, singleton dimensions of input or output signals cannot have a variable size.
coder.resize
|coder.Type
|coder.ArrayType
|coder.EnumType
|coder.FiType
|coder.PrimitiveType
|coder.StructType
|coder.CellType
|coder.ClassType
|codegen
|coder.OutputType