Single output/update function
Execution entry-point function that includes code for output and update functions
Model Configuration Pane: Code Generation / Interface
Description
The Single output/update function parameter specifies whether the code generator produces one execution entry-point function (
) that includes code for output and update functions or produces separate output and update entry-point functions (model
_step
and model
_output
).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 Around | Customized ert_main.c | Customized 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 call and the call, read the model External outputs global data structure (defined in ). | X | |
Select the Single output/update function parameter and insert code in the generated 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 ). Then, restore the value after the update code completes. | X | X |
Place a Zero-Order Hold block before the continuous output port. | X | X |
Dependencies
To enable this parameter:
Set the Code interface packaging parameter to
Non-reusable function
orReusable function
.Clear the Minimize algebraic loop occurrences parameter.
Settings
On
(default) | Off
- On
Enables generation of a single execution entry-point function (
) for a model. This function contains the output and update function code for the blocks in the model and is called bymodel
_steprt_OneStep
to execute processing for one clock period of the model at interrupt level.- Off
Disables generation of a single execution entry-point function. The code generator produces separate
andmodel
_output
entry-point functions.model
_update
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.
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
Application | Setting |
---|---|
Debugging | On |
Traceability | On |
Efficiency | On |
Safety precaution | No recommendation |
Programmatic Use
Parameter: CombineOutputUpdateFcns |
Type: character vector |
Value: 'on' | 'off' |
Default: 'on' |
Version History
Introduced before R2006a