Create and Edit Input Types by Using the Coder Type Editor - MATLAB & Simulink (original) (raw)

C/C++ source code includes type declarations for all variables. MATLABĀ® code does not include explicit type declarations. To allow the generation of C/C++ code with specific types, you must specify the properties (class, size, and complexity) of all input variables to the MATLAB entry-point functions during C/C++ or MEX code generation. An_entry-point function_ is a top-level MATLAB function from which you generate code. The code generator uses these input properties to determine the properties of all variables in the generated code. Different input type specifications can cause the same MATLAB code to produce different versions of the generated code.

When you generate C/C++ or MEX code at the command line, one of the ways to specify the properties of an input argument is by using a coder.Type object that contains information about class, size, and complexity (and sometimes other properties) of the argument. You can create and edit coder.Type objects programmatically at the command line, or interactively by using the Coder Type Editor.

For more information about creating coder.Type objects at the command line, see coder.typeof and coder.newtype.

Note

To create and edit composite types such as structures and cell arrays, or types that have many customizable parameters such as embedded.fi, use the Coder Type Editor. Examples of such types are shown later in this topic.

Open the Coder Type Editor

To open the Coder Type Editor, do one of the following:

Common Editor Actions

By using the toolstrip buttons in the type editor, you can perform these actions:

These are some additional actions that you can perform in the Coder Type Editor:

Type Browser Pane

The Type Browser pane shows the name, class, and size of thecoder.Type objects that are currently loaded in the type editor. For composite types such as structures, cell arrays, or classes, you can expand the display of the code.Type object in the Type Browser pane. The expanded view shows the name, class, and complexity of the individual fields or properties of the composite type.

Type Browser pane, showing the type objects aType, bType, and cType. bType and cType are composite objects.

Visual Indicators on the Type Browser

Indicator Description
expander The type has fields or properties that you can see by clicking the expander.
{:} Homogeneous cell array (all elements have the same properties).
{n} nth element of a heterogeneous cell array.
:n Variable-size dimension with an upper bound of n.
:inf Variable-size dimension that is unbounded.

Type Properties Pane

The type properties pane displays the class (data type), size, and other properties of the coder.Type object that is currently selected in the Type Browser. For composite types such as structures and classes, this pane also shows the name, class, and size of each constituent field or property.

To edit the name, class, and size of a field in place, double-click the item.

Close-up of the "Fields" section of the Type Properties pane, showing a the f1 field selected for editing

Alternatively, click a field. The view in the type editor pane changes to display the properties of that field. Edit name, class(data type), size, or other properties in the pane.

Pane displaying the properties of the f1 field of the bType variable

The breadcrumb shows the nested path to the field that is currently open in the type properties pane. Click a field in the breadcrumb to display it in the pane. You can also edit the name of a type directly in the breadcrumb.

Variable bType selected for editing

MATLAB Code Pane

The MATLAB Code pane displays the MATLAB script that creates the coder.Type object that is currently selected in the Type Browser. To automate the creation of this type, copy this script and include it in your build script.

MATLAB code pane showing a script that can be used to recreate fields f1, f2, and f2 of variable bType

See Also

coderTypeEditor | coder | coder.typeof | coder.newtype