Simulink.AliasType
Create alias for signal and parameter data type
Description
Use aSimulink.AliasType
to create an alias of a built-in data type such asint8
。
The 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:
Floating-point types:
一半
,single
,double
Integer types:
int8
,uint8
,int16
,uint16
,int32
,uint32
,int64
, oruint64
。Fixed-Point Designer™ types beginning with
sfix
,ufix
, orflt
。
You create the object in the base workspace or a 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.
Using aliases to specify signal and parameter data types can greatly simplify global changes to the data types that a model specifies. In particular, changing the data type of all signals, states, and parameters whose data type is specified by an alias requires changing only the base type of the alias. By contrast, changing the data types of signals, states, and parameters whose data types are specified by an actual type name requires respecifying the data type of each signal and parameter individually.
You can use objects of this class to create an alias for Simulink®built-in data types, fixed-point data types, enumerated data types,Simulink.NumericType
objects, and otherSimulink.AliasType
objects. 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®).
一个lternatively, to define and name a numeric data type, you can use an object of the classSimulink.NumericType
。
Creation
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 ExplorerModel Hierarchypane, select
Base Workspace
。You must create data type aliases in the MATLAB workspace or in a data dictionary. If you attempt to create an alias in a model workspace, Simulink software displays an error.
From the Model Explorer一个ddmenu, selectSimulink.AliasType。
Simulink software creates an instance of a
Simulink.AliasType
object and assigns it to a variable named一个lias
in the MATLAB workspace.Rename the variable to a more appropriate name, for example, a name that reflects its intended usage.
To change the name, edit the name displayed in theNamefield on the Model ExplorerContentspane.
On the Model ExplorerDialogpane, in theBase typefield, enter the name of the data type that this alias represents.
You can specify the name of any existing standard or user-defined data type in this field. Skip this step if the base type is
double
(the default).
生成Simulink.AliasType
objects that correspond totypedef
statements in your external C code, consider using theSimulink.importExternalCTypes
function.
To create a data type alias programmatically, use theSimulink.AliasType
function described below.