包:编码器
超类:编码器。ArrayType
代表的MATLAB类
指定生成的代码可以接受的值类对象集。只能与codegen
arg游戏
选择。不要将输入传递给生成的MEX函数。
请注意
您还可以创建和编辑编码器。类型
对象通过使用编码器类型编辑器进行交互。看到使用编码器类型编辑器创建和编辑输入类型.
创建一个t
= coder.typeof (value_class_object
)编码器。ClassType
对象的对象value_class_object
.
创建一个t
= coder.newtype (value_class_name
)编码器。ClassType
对象的一个类对象value_class_name
.
|
值类对象,从中创建 v = myValueClass;t = coder.typeof (v); t = coder.typeof (myValueClass(2、3); |
|
在MATLAB中值类定义文件的名称®路径。指定为字符向量或字符串标量。例如: t = coder.newtype (“myValueClass”);
|
当你创建编码器。ClassType
对象t
从值类对象v
通过使用coder.typeof
的性质t
和的性质一样吗v
与属性常数
设置为假
.
价值。要了解值类如何影响复制操作,请参见复制对象.
基于工作区中的示例对象创建类型。
创建值类myRectangle
.
classdefmyRectangle属性长度;宽度;结束方法函数obj = myRectangle (l, w)如果Nargin > 0 obj。长度= l;obj。宽度= w;结束结束函数Area = calcalarea (obj)长度* obj.width;结束结束结束
创建一个函数,接受的对象为myRectangle
作为输入。
函数z = getarea(右)% # codegenz =钙质海绵纲(r);结束
创建一个对象myRectangle
.
v = myRectangle(1、2)
v = myRectangle带有属性:length: 1 width: 2
创建一个编码器。ClassType
对象的基础上v
.
t = coder.typeof (v)
t =编码器。ClassType1×1 myRectangle length: 1×1 double width : 1×1 double
coder.typeof
创建一个编码器。ClassType
具有相同属性名称和类型的v
有。
生成的代码getarea
.属性指定输入类型编码器。ClassType
对象,t
,arg游戏
选择。
codegengetareaarg游戏{t}报告
coder.newtype
创建一个编码器。ClassType
对象的值类的对象mySquare
通过使用coder.newtype
.
类创造价值mySquare
它有一个性质,一边
.
classdefmySquare属性一面;结束方法函数obj = mySquare (val)如果Nargin > 0 obj。一边= val;结束结束函数A = calcalarea (obj)* obj.side;结束结束结束
创建一个编码器。ClassType
类型mySquare
.
t = coder.newtype (“mySquare”)
上一步创建一个编码器。ClassType
类型t
,但不指定的任何属性mySquare
到它。以确保t
具有的所有性质mySquare
,指定类型一边
通过使用t.Properties
.
t.Properties.side = coder.typeof (2)
在创建编码器。ClassType
,可以修改属性的类型。例如:
t = code .typeof(myClass)prop1 = coder.typeof (int16 (2));t.Properties。prop2 =编码器。typeof([1 2 3]);
在创建编码器。ClassType
,您可以添加属性。例如:
t = code .typeof(myClass)newprop1 = coder.typeof (int8 (2));t.Properties。newprop2 =编码器。typeof ((1 2 3));
的属性在生成代码时编码器。ClassType
对象codegen
必须与类定义文件中的属性一致。但是,如果类定义文件具有代码不使用的属性,则编码器。ClassType
对象不必包含这些属性。代码生成器将删除不使用的属性。
编码器。类型
|编码器。PrimitiveType
|编码器。EnumType
|编码器。CellType
|编码器。FiType
|编码器。常数
|编码器。ArrayType
|coder.newtype
|coder.typeof
|coder.resize
|codegen
|编码器
|coder.cstructname