Contents

Including Custom C Code Functions and Structures

This model shows how Stateflow® allows you to incorporate and to call your custom-written C-Code functions.

In this particular example, a C-code function defined in my_function.c and a structure that is defined in my_header.h are included in the chart. MY_FUNCTION simply multiplies its input by 2. The structure in my_header.h is defined as follows:

typedef struct { real_T a; int8_T b[10]; } MyStruct;

In the model, we access the structure member using the dot notation: MyStruct.a and also with the use of a pointer: gMyStructPointerVar ->b[1].

Was this topic helpful?