Skip to Main Content Skip to Search
Product Documentation

coder.StructType class - Package: coder
Superclasses: coder.ArrayType

Represent a set of MATLAB structure arrays

Description

Specifies the set of structure arrays that the generated code should accept. Use with the fiaccel -args option.

Construction

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, all 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 all the dimensions, except if the dimension is 1 or 0, which are assumed to be fixed, or if the dimension is unbounded, which is assumed to be always variable sized.

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, all 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 all the dimensions of the type, except if the dimension is 1 or 0, which is assumed to be always 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 to optimize application performance. By default, the structure is not aligned on any 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 all 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 string.

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 in the MATLAB Programming Fundamentals documentation.

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
 

Create a coder.StructType object that uses an externally-defined structure type.

  1. Create a type that uses an externally-defined structure type.

    S.a = coder.typeof(double(0));
    S.b = coder.typeof(single(0));
    T = coder.typeof(S);
    T = coder.cstructname(T,'mytype','extern','HeaderFile','myheader.h');
    
    T = 
    
    coder.StructType
       1x1 extern mytype (myheader.h) struct
          a: 1x1 double 
          b: 1x1 single
  2. View the types of the structure fields.

    T.Fields
    ans = 
    
        a: [1x1 coder.PrimitiveType]
        b: [1x1 coder.PrimitiveType]

See Also

coder | coder.ArrayType | coder.Constant | coder.EnumType | coder.FiType | coder.newtype | coder.PrimitiveType | coder.resize | coder.Type | coder.typeof | fiaccel

  


Free Early Verification Kit

Learn how to apply early verification to your development process through these technical resources.

How much time do you spend on testing to ensure implementation meets system-level requirements?

 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS