Single output/update function
Description
Specify whether to generate the
function. When using
Embedded Coder® for a component model that is configured with a service interface,
this parameter is not supported.model
_step
Category: Code Generation > Interface
Settings
Default: on
On
Generates the
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
Does not combine output and update function code into a single function, and instead generates the code in separate
andmodel
_output
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.
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 fromert_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 fromert_main
after the base-rate model step potentially reflects intervening minor time steps. The following 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, inert_main
, between the
call and themodel
_output
call, read the modelmodel
_updateExternal outputs
global data structure (defined in
).model
.hX Select the Single output/update function parameter and insert code in the generated
ormodel
.c.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 modelExternal outputs
global data structure (defined in
). Then, restore the value after the update code completes.model
.hX X Place a Zero-Order Hold block before the continuous output port. X X
Command-Line Information
Parameter:
CombineOutputUpdateFcns |
Type: character vector |
Value:
'on' | 'off' |
Default:
'on' |
Recommended Settings
Application | Setting |
---|---|
Debugging | On |
Traceability | On |
Efficiency | On |
Safety precaution | No recommendation |