Hauptinhalt

simulink.compiler.setPostStepFcn

R2026b

Register callback function to execute after each time step in simulation

Description

simin = simulink.compiler.setPostStepFcn(simin,func) registers the post-step callback function func on the Simulink.SimulationInput object simin. The post-step callback function executes during simulation after each time step.

simin = simulink.compiler.setPostStepFcn(simin,func,Decimation=d) reduces the execution frequency of the post-step callback function by the decimation factor d.

For an example of an app that implements a post-step callback function, see Visualize Live Simulation Results in Deployed Applications

Input Arguments

collapse all

Simulation configuration, specified as a Simulink.SimulationInput object.

Post-step callback function, specified as a MATLAB function handle. The post-step callback function accepts the time of the previous time step as an input argument.

Example: simin = simulink.compiler.setPostStepFcn(simin,@(t) postStepFcn(t)) registers a post step callback function named postStepFcn.

Decimation factor for post step callback function, specified as a positive integer. The decimation factor specifies when the callback function executes during simulation. Specifying a decimation factor can speed up simulation by reducing the total number of function evaluations.

For the default decimation factor of 1, the callback executes after every time step. If the decimation factor is 2, the callback executes after every other time step.

Version History

Introduced in R2020b