文档Help Center
Create alias for signal and parameter data type
Use a金宝appsimulink.Airstype创建一个内置数据类型的别名,例如int8。
金宝appsimulink.Airstype
int8
这name of the object is the alias. The data type to which an alias refers, such asint8,,,,is the base type. Alias names cannot be:
浮点类型:一半,,,,单身的,,,,double
一半
单身的
double
Integer types:int8,,,,UINT8,,,,int16,,,,uint16,,,,int32,,,,UINT32,,,,int64, 或者Uint64。
UINT8
int16
uint16
int32
UINT32
int64
Uint64
Fixed-Point Designer™ types beginning withsfix,,,,ufix, 或者flt。
sfix
ufix
flt
你在基地工作区中创建对象或data dictionary. To use the alias, you use the name of the object to set data types for signals, states, and parameters in a model.
使用别名来指定信号和参数数据类型可以极大地简化模型指定数据类型的全局更改。特别是,更改所有信号,状态和参数的数据类型的数据类型是由别名指定的,仅需要更改别名的基本类型。相比之下,更改数据类型的信号,状态和参数的数据类型是由实际类型名称指定的,需要分别对每个信号和参数的数据类型进行重新定义。
您可以使用此类的对象为Simulink创建一个别名金宝app®built-in data types, fixed-point data types, enumerated data types,金宝appsimulink.numerictypeobjects, and other金宝appsimulink.Airstypeobjects. The code that you generate from a model (Simulink Coder™)uses the alias only if you use an ERT-based system target file (Embedded Coder®)。
金宝appsimulink.numerictype
另外,要定义和命名数字数据类型,您可以使用类的对象金宝appsimulink.numerictype。
You can use either the Model Explorer or MATLAB®commands to create a data type alias.
To use the Model Explorer to create an alias:
On the Model Explorer模型层次结构窗格,选择基本工作区。
基本工作区
您必须在MATLAB工作区或数据字典中创建数据类型别名。如果您尝试在模型工作区中创建别名,则Simulink软件会显示错误。金宝app
From the Model Explorer添加菜单,选择金宝appsimulink.Airstype。
Simulink software creates an instance of a金宝appsimulink.Airstype对象并将其分配给一个命名的变量一个lias在MATLAB工作区中。
一个lias
将变量重命名为更合适的名称,例如反映其预期用法的名称。
To change the name, edit the name displayed in the姓名field on the Model ExplorerContentspane.
On the Model Explorer对话pane, in the基本类型字段,输入此别名代表的数据类型的名称。
You can specify the name of any existing standard or user-defined data type in this field. Skip this step if the base type isdouble(the default).
生成金宝appsimulink.Airstype对应的对象typedefstatements in your external C code, consider using theSimulink.importExternalCTypes功能。
typedef
Simulink.importExternalCTypes
要以编程方式创建数据类型别名,请使用金宝appsimulink.Airstype下面描述的功能。
aliasObj = Simulink.AliasType
aliasobj = 金宝appsimulink.aliastype(basetype)
例子
aliasObj = Simulink.AliasType返回a金宝appsimulink.Airstype具有默认属性值的对象。
aliasObj = Simulink.AliasType(底型)返回a金宝appsimulink.Airstypeobject and initializes the value of the底型property by using底型。
aliasObj = Simulink.AliasType(底型)
底型
expand all
有关属性的信息,请参阅金宝appsimulink.Airstype对象,请参阅金宝appsimulink.Airstype属性对话框。
'double'
姓名of the base data type that this alias renames, specified as a character vector or string scalar. You can specify the name of a standard data type, such asint8or一半,或自定义数据类型的名称,例如另一个名称金宝appsimulink.Airstype对象或枚举的名称。
要指定定点数据类型,您可以使用调用FIXDTfunction, such as'fixdt(0,16,7)'。
FIXDT
'fixdt(0,16,7)'
您可以在一个例外情况下指定非标准数据类型,例如金宝appsimulink.numerictypeobject, by specifying the data type name. The exception is a金宝appsimulink.numerictype谁的DataTypeModeisFixed-point: unspecified scaling。
DataTypeMode
Fixed-point: unspecified scaling
笔记
Fixed-point: unspecified scaling是一种部分指定的类型,其定义是由使用该块完成的金宝appsimulink.numerictype。Forbidding its use in alias types avoids creating aliases that have different base types depending on where they are used.
对应于基本类型in the property dialog box.
Example:'int8'
'int8'
Example:'Myotheralias'
'Myotheralias'
数据类型:char|细绳
char
细绳
DataScope
'汽车'
“出口”
“进口”
规范生成或导入类型定义(typedef)in the generated code (Simulink Coder),指定为'汽车',,,,'Exported, 或者“进口”。
'Exported
该表显示了每个选项的效果。
HeaderFile
model_types.h
model
rtwtypes.h
type。h
type
For more information, seeControl File Placement of Custom Data Types(嵌入式编码器)。
对应于Data scopein the property dialog box.
Description
''
数据类型别名的自定义描述,指定为字符向量。
对应于Descriptionin the property dialog box.
Example:'This type alias corresponds to a floating-point implementation.'
'This type alias corresponds to a floating-point implementation.'
数据类型:char
包含类型定义的标头文件的名称(typedef)在生成的代码中,指定为字符向量。
If this property is specified, the specified name is used during code generation for importing or exporting. If this property is empty, the value defaults totype。hifDataScopeequals“进口”or“出口”,或默认为model_types.hifDataScopeequals'汽车'。
默认情况下,生成#包括指令使用预处理器定界符“代替<and>。生成the directive#include ,,,,specifyHeaderFile作为''。
#包括
“
<
>
#include
对应于Header filein the property dialog box.
Example:'myhdr.h'
'myhdr.h'
Example:'myHdr'
'myHdr'
Example:'myHdr.hpp'
'myHdr.hpp'
collapse all
为枚举类型创建一个名称的别名Sldemosign:
Sldemosign
myenumalias = 金宝appsimulink.Airstype('Enum: SlDemoSign');
To create an alias for a fixed-point data type by using a金宝appsimulink.Airstypeobject, set the底型property of the object by using a call to theFIXDT功能。的价值底型必须指定为字符向量。
例如,此代码为具有单词长度的未签名的定点数据类型创建一个别名16and fraction length7。
16
7
myFixptAlias = Simulink.AliasType; myFixptAlias.BaseType ='fixdt(0,16,7)';
一个金宝appsimulink.Airstypeobject appears in the generated code as atypedefstatement. The generated code uses the named type to define and declare data (variables).
这金宝appsimulink.Airstypeclass does not support multiword base data types for code generation.
您单击了与此MATLAB命令相对应的链接:
通过在MATLAB命令窗口中输入该命令。Web浏览器不支持MATLAB命令。金宝app
选择一个网站以获取可用的翻译内容,并查看本地事件和优惠。根据您的位置,我们建议您选择:。
You can also select a web site from the following list:
选择中国网站(中文或英语)以获得最佳场地性能。其他Mathworks乡村网站未针对您所在的访问进行优化。
Contact your local office
Get trial now