coder.StructType class

Package: coder
Superclasses: coder.ArrayType

Represent set of MATLAB structure arrays

Description

Specifies the set of structure arrays that the generated code should accept. Use only with the fiaccel -args option. Do not pass as an input to a generated MEX function.

Construction

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.

t=coder.typeof(struct_v) creates a coder.StructType object for a structure with the same fields as the scalar structure struct_v.

t=coder.typeof(struct_v, sz, variable_dims) returns a modified copy of coder.typeof(struct_v) with (upper bound) size specified by sz and variable dimensions variable_dims. If sz specifies inf for a dimension, then the size of the dimension is assumed to be unbounded and the dimension is assumed to be variable sized. When sz is [], the (upper bound) sizes of struct_v remain unchanged. If the variable_dims input parameter is not specified, the dimensions of the type are assumed to be fixed except for those that are unbounded. When variable_dims is a scalar, it is applied to the bounded dimensions that are not 1 or 0 (which are assumed to be fixed).

t=coder.newtype('struct', struct_v, sz, variable_dims) creates a coder.StructType object for an array of structures with the same fields as the scalar structure struct_v and (upper bound) size sz and variable dimensions variable_dims. If sz specifies inf for a dimension, then the size of the dimension is assumed to be unbounded and the dimension is assumed to be variable sized. When variable_dims is not specified, the dimensions of the type are assumed to be fixed except for those that are unbounded. When variable_dims is a scalar, it is applied to the dimensions of the type, except if the dimension is 1 or 0, which is assumed to be fixed.

Input Arguments

struct_v

Scalar structure used to specify the fields in a new structure type.

sz

Size vector specifying each dimension of type object.

Default: [1 1] for coder.newtype

variable_dims

Logical vector that specifies whether each dimension is variable size (true) or fixed size (false).

Default: false(size(sz)) | sz==Inf for coder.newtype

Properties

Alignment

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. This capability allows you to take advantage of target-specific function implementations that require data to be aligned. By default, the structure is not aligned on a specific boundary so it will not be matched by CRL functions that require alignment.

Alignment must be either -1 or a power of 2 that is no more than 128.

ClassName

Class of values in this set.

Extern

Whether the structure type is externally defined.

Fields

A structure giving the coder.Type of each field in the structure.

HeaderFile

If the structure type is externally defined, name of the header file that contains the external definition of the structure, for example, "mystruct.h".

By default, the generated code contains #include statements for custom header files after the standard header files. If a standard header file refers to the custom structure type, then the compilation fails. By specifying the HeaderFile option, MATLAB® Coder™ includes that header file exactly at the point where it is required.

Must be a non-empty character vector or string scalar.

SizeVector

The upper-bound size of arrays in this set.

VariableDims

A vector used to specify whether each dimension of the array is fixed or variable size. If a vector element is true, the corresponding dimension is variable size.

Copy Semantics

Value. To learn how value classes affect copy operations, see Copying Objects.

Examples

Create a type for a structure with a variable-size field.

x.a = coder.typeof(0,[3 5],1);
x.b = magic(3);
coder.typeof(x)
% Returns 
% coder.StructType
%    1x1 struct
%      a:  :3x:5 double
%      b:  3x3  double
% ':' indicates variable-size dimensions

Introduced in R2011a