主要内容

simulink.compiler.setExternalOutputsFcn

R2026b

Register callback function to read and process data for top-level output ports during simulation

Description

simin = simulink.compiler.setExternalOutputsFcn(simin,func) registers func as the external outputs callback function on the Simulink.SimulationInput object simin. The external outputs function dynamically processes top-level output port data during simulation. The simulation executes the function after each time step and provides the output port data as input to the function.

Input Arguments

collapse all

Simulation configuration, specified as a Simulink.SimulationInput object.

External outputs callback function, specified as a MATLAB function handle. The external outputs callback function reads and processes top-level output port data during simulation.

The external outputs callback function accepts three input arguments.

  • idx – Index of top-level output port, specified as a scalar integer.

  • t – Simulation time, specified as a scalar number.

  • d – Value read from output port.

Example: simin = simulink.compiler.setExternalOutputsFcn(simin,@(idx,t,d) processOutput(idx,t,d)) registers an external outputs callback function named processOutput.

Version History

Introduced in R2020b