model_initialize

Initialization entry-point function in generated code for Simulink model

Syntax

void model_initialize(void)

Calling Interfaces

The calling interface generated for this function differs depending on the value of the model configuration parameter Code interface packaging:

  • C++ class (default for C++ language) — Generated function is encapsulated into a C++ class method. Required model data is encapsulated into C++ class attributes.

  • Nonreusable function (default for C language) — Generated function passes (void). Model data structures are statically allocated, global, and accessed directly in the model code.

  • Reusable function — Generated function passes the real-time model data structure, by reference, as an input argument. The real-time model data structure is exported with the model.h header file.

    For an ERT-based model, you can use model configuration parameter Pass root-level I/O as to control how root-level input and output arguments are passed to the function. They can be included in the real-time model data structure, passed as individual arguments, or passed as references to an input structure and an output structure.

    For a GRT-based model, the generated model.c source file contains an allocation function that dynamically allocates model data for each instance of the model. For an ERT-based model, you can use model configuration parameter Use dynamic memory allocation for model initialization to control whether an allocation function is generated.

    • When set, you can restart code generated from the model from a single execution instance. The sequence of function calls from the main.c is allocfcn, model_init, model_term, allocfcn, model_init, model_term.

    • When cleared,

If you have an Embedded Coder® license, for Nonreusable function code interface packaging, you can use the Code Mapping Editor to customize the name of the initialize function interface. See Override Default Naming for Individual C Entry-Point Functions (Embedded Coder).

Description

The generated model_initialize function contains initialization code for a Simulink® model and should be called once at the start of your application code.

Do not use the model_initialize function to reset the real-time model data structure (rtM).

Introduced before R2006a