coder.newtype
Create coder.Type
object to represent type of an entry-point
function input
Syntax
Description
The coder.newtype
function is an advanced function that
you can use to control the coder.Type
object. Consider
using coder.typeof
instead of
coder.newtype
. The function coder.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 object t
.
Note
You can also create and edit coder.Type
objects
interactively by using the Coder Type Editor. See Create and Edit Input Types by Using the Coder Type Editor.
creates a t
= coder.newtype(numeric_class
,sz
,variable_dims
)coder.Type
object representing values of
class numeric_class
, sizes sz
(upper bound),
and variable dimensions variable_dims
. If sz
specifies inf
for a dimension, then the size of the dimension is
unbounded and the dimension is variable-size. When variable_dims
is not specified, the dimensions of the type are fixed except for those that are
unbounded. When variable_dims
is a scalar, it is applied to type
dimensions that are not 1
or 0
, which are
fixed.
creates a t
= 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 a t
= coder.newtype('struct',struct_fields
,sz
,variable_dims
)coder.StructType
object for an array of
structures that has the same fields as the scalar structure
struct_fields
. The structure array type has the size
specified by sz
and variable-size dimensions specified by
variable_dims
.
creates a t
= coder.newtype('cell',cells
,sz
,variable_dims
)coder.CellType
object for a cell array
that has the cells and cell types specified by cells
. The cell
array type has the size specified by sz
and variable-size
dimensions specified by variable_dims
. You cannot change the
number of cells or specify variable-size dimensions for a heterogeneous cell
array.
creates a t
= coder.newtype('embedded.fi',numerictype,sz
,variable_dims
,
Name,Value
)coder.FiType
object representing a set
of fixed-point values that have numerictype
and additional
options specified by one or more Name, Value pair arguments.
creates a t
= coder.newtype(enum_value
,sz
,variable_dims
)coder.Type
object representing a set of
enumeration values of class enum_value
.
creates a t
= coder.newtype('class_name'
)coder.ClassType
object for an object of
the class class_name
. The new object does not have
any properties of the class
class_name
.
creates a
t
= coder.newtype('string')coder.StringType
object 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, set the
StringLength
property to the required size and set
VariableStringLength
to true
. For example,
t.StringLength = 10
and t.VariableStringLength =
true
specifies that the string scalar is variable-size with an upper
bound of 10.
Examples
Input Arguments
Output Arguments
Limitations
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 using
coder.newtype
to represent GPU inputs, the memory allocation (malloc) mode property of the GPU code configuration object to'discrete'
.
Tips
The
coder.newtype
function fixes the size of a singleton dimension unless thevariable_dims
argument explicitly specifies that the singleton dimension has a variable size.For example, this code specifies a 1-by-:10 double. The first dimension (the singleton dimension) has a fixed size. The second dimension has a variable size.
By contrast, this code specifies a :1-by-:10 double. Both dimensions have a variable size.t = coder.newtype('double',[1 10],1)
t = coder.newtype('double',[1 10],[1 1])
For a MATLAB Function block, singleton dimensions of input or output signals cannot have a variable size.
Alternatives
Version History
Introduced in R2011a
See Also
coder.resize
| coder.Type
| coder.ArrayType
| coder.EnumType
| coder.FiType
| coder.PrimitiveType
| coder.StructType
| coder.CellType
| fiaccel
| coder.OutputType
(MATLAB Coder)