Main Content

Single output/update function

Execution entry-point function that includes code for output and update functions

Model Configuration Pane: Code Generation / Interface


The Single output/update function parameter specifies whether the code generator produces one execution entry-point function (model_step) that includes code for output and update functions or produces separate output and update entry-point functions (model_output and model_update).

This parameter is not supported for models that are configured with an ERT-based system target file and service code interface.

If you customize ert_main.c or .cpp to read model outputs after each base-rate model step, selecting parameters Support: continuous time and Single output/update function can cause output values read from ert_main for a continuous output port to differ from the corresponding output values in the logged data for the model. This is because, while logged data is a snapshot of output at major time steps, output read from ert_main after the base-rate model step potentially reflects intervening minor time steps. This table lists workarounds that eliminate the discrepancy.

Work AroundCustomized ert_main.cCustomized ert_main.cpp
Separate the generated output and update functions (clear the Single output/update function parameter), and insert code in ert_main to read model output values reflecting only the major time steps. For example, in ert_main, between the model_output call and the model_update call, read the model External outputs global data structure (defined in model.h). X 
Select the Single output/update function parameter and insert code in the generated model.c or .cpp file to return model output values reflecting only major time steps. For example, in the model step function, between the output code and the update code, save the value of the model External outputs global data structure (defined in model.h). Then, restore the value after the update code completes.XX
Place a Zero-Order Hold block before the continuous output port.XX


To enable this parameter:

  • Set the Code interface packaging parameter to Non-reusable function or Reusable function.

  • Clear the Minimize algebraic loop occurrences parameter.


On (default) | Off

Enables generation of a single execution entry-point function (model_step) for a model. This function contains the output and update function code for the blocks in the model and is called by rt_OneStep to execute processing for one clock period of the model at interrupt level.


Disables generation of a single execution entry-point function. The code generator produces separate model_output and model_update entry-point functions.


Errors or unexpected behavior can occur if a Model block is part of a cycle, the Model block is a direct feedthrough block, and an algebraic loop results. For more information about direct feed through, see Algebraic Loop Concepts.

The code generator ignores this parameter for a referenced model if at least one of these conditions applies to the model:

  • Is multi-rate

  • Has a continuous sample time

  • Is logging states by using the States or Final states data import and export parameter.

Recommended Settings

Safety precaution

No recommendation

Programmatic Use

Parameter: CombineOutputUpdateFcns
Type: character vector
Value: 'on' | 'off'
Default: 'on'

Version History

Introduced before R2006a