Main Content

Single output/update function

Description

Specify whether to generate the model_step function.

Category: Code Generation > Interface

Settings

Default: on

On

Generates the model_step function 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.

Off

Does not combine output and update function code into a single function, and instead generates the code in separate model_output and model_update functions.

Tips

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.

Simulink® Coder™ ignores this parameter for a referenced model if any of the following conditions apply to that model:

  • Is multi-rate

  • Has a continuous sample time

  • Is logging states (using the States or Final states parameters in the Configuration Parameters > Data Import/Export pane

Dependencies

  • Setting Code interface packaging to C++ class forces on and disables this option.

  • This option and Classic call interface are mutually incompatible and cannot both be selected through the GUI. Selecting Classic call interface forces off and disables this option and clearing Classic call interface enables (but does not select) this option.

  • When you use this option, you must clear the option Minimize algebraic loop occurrences on the Model Referencing pane.

  • If you customize ert_main.c or .cpp to read model outputs after each base-rate model step, selecting both 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. The following 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

Command-Line Information

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

Recommended Settings

ApplicationSetting
DebuggingOn
TraceabilityOn
EfficiencyOn
Safety precaution

No recommendation

Related Topics