Documentation

Coder.StructTypeclass

Package:编码器
Superclasses:编码器.ArrayType

Represent set ofMATLABstructure arrays

Description

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

Construction

t=coder.typeof(struct_v)creates aCoder.StructType与标量结构相同字段的结构的对象struct_v.

t=coder.typeof(struct_v,sz,variable_dims)returns a modified copy ofcoder.typeof(struct_v)与(上限)大小指定szand variable dimensionsvariable_dims. Ifszspecifiesinf对于一个维度,则假定维度的大小是无限的,并且假定尺寸是可变尺寸的。什么时候szis [], the (upper bound) sizes ofstruct_vremain unchanged. If thevariable_dims未指定输入参数,假定该类型的尺寸是固定的,除非无界的尺寸。什么时候variable_dims是标量,将其应用于没有的界限1或者0(which are assumed to be fixed).

t= coder.newtype('struct',struct_v,sz,variable_dims)creates aCoder.StructType具有与标量结构相同字段的一系列结构的对象struct_vand (upper bound) sizeszand variable dimensionsvariable_dims. Ifszspecifiesinf对于一个维度,则假定维度的大小是无限的,并且假定尺寸是可变尺寸的。什么时候variable_dimsis not specified, the dimensions of the type are assumed to be fixed except for those that are unbounded. Whenvariable_dims是标量,它应用于类型的尺寸,除非尺寸为1或者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编码器

variable_dims

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

Default:false(size(sz))|sz == inf for编码器

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必须是-1或权力2that is no more than128.

ClassName

该集合中的值类。

Extern

Whether the structure type is externally defined.

字段

A structure giving thecoder.type结构中的每个字段。

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”.Specify the path to the file using thecodegen-一世选项或Additional include directoriesparameter in theMATLAB®Coder™project settings dialog boxCustom Codetab.

By default, the generated code contains#includestatements 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 theHeaderFile选项,MATLAB Coder在需要的点上准确包含该标头文件。

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

SizeVector

该组中的阵列的上限大小。

VariableDims

用于指定数组的每个维度是固定还是可变大小的向量。如果向量元素是真的,相应的维度是可变大小。

Copy Semantics

价值。要了解价值类别如何影响复制操作,请参见Copying Objects(MATLAB)。

Examples

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

X.A = coder.typeof(0,[3 5],1);X.B =魔术(3);coder.typeof(x)%返回%coder.structtype%1x1 struct%a :: 3x:5 double%b:3x3 double%':'指示变量尺寸尺寸

Create aCoder.StructType对象然后致电codegento generate a C library for a functionfcn.m这有一个输入ut parameter of this type

  1. Create a new structure type.

    ta = coder.newtype('int8',[1 1]);tb = coder.newtype('double',[1 2],[1 1]);z = coder.newtype('struct',struct('a',ta,'b',tb))%返回%coder.structtype%1x1 struct%a:1x1 int8%b :: 1x:2 double
  2. Callcodegen为MATLAB函数生成C库fcn.m这有一个输入ut parameter of this type.

    % Use the -config:lib option to generate a C library codegen -config:lib fcn -args {z}

Create aCoder.StructTypeobject 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(单(0));t = coder.typeof(s);t = coder.cstructname(t,'我的风格',“外部”,'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]

Introduced in R2011a