Create alias for signal and parameter data type
Use a Simulink.AliasType
to create an alias of a built-in
data type such as int8
.
The name of the object is the alias. The data type to which an alias refers, such as
int8
, is the base type. Alias names cannot be:
Floating-point types: half
, single
,
double
Integer types: int8
, uint8
,
int16
, uint16
,
int32
, uint32
,
int64
, or uint64
.
Fixed-Point Designer™ types beginning with sfix
,
ufix
, or flt
.
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 other Simulink.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®).
Alternatively, to define and name a numeric data type, you can use an object of the
class Simulink.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 Model Hierarchy pane,
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 Add menu, select Simulink.AliasType.
Simulink software creates an instance of a
Simulink.AliasType
object and assigns it to a variable
named Alias
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 the Name field on the Model Explorer Contents pane.
On the Model Explorer Dialog pane, in the Base type field, 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).
To generate Simulink.AliasType
objects that
correspond to typedef
statements in your external C code, consider
using the Simulink.importExternalCTypes
function.
To create a data type alias programmatically, use the
Simulink.AliasType
function described below.