Main Content

Define an Alias Type in C Function Block

This example shows how to specify alias data types in C Function block and integrate a custom C code that uses the alias data type into a Simulink® model. In this example, the alias data type is defined in the multiply_func.h file, and the function using alias data type is defined in the multiply_func.c file. The source ( .c ) and the header ( .h ) files are specified in the Simulation Target pane of the Configuration Parameters dialog box. Calculations are performed using the functions in the source file.

Generate custom data type using Simulink.importExternalCTypes function.

Simulink.importExternalCTypes('multiply_func.h');

Open the model.

open_system('mCFunction_AliasType')

Alias Type in the Header File

The keyword typedef defines an alias type in the header file. In this example, an alias for the double data type is defined as typedef double doubleAlias in multiply_func.h.

Alias Type Specification in the block

The data type doublealias is specified in the Type column of the Ports and Parameters table of the C Function Block Parameters dialog box.

See Also

Objects

Blocks