Main Content


Specify a MATLAB function to run before start of each simulation through SimulationInput object, in


in = in.setPreSimFcn(func) registers the callback function associated with the function handle func before each simulation starts. The Simulink.SimulationInput object is passed as an argument to this function. func is any MATLAB® function and can be used to modify the Simulink.SimulationInput object. If you use func to modify the Simulink.SimulationInput object, you must return Simulink.SimulationInput object as the only output argument.

Input Arguments

collapse all

Function to run before each simulation starts, specified as a function handle or a function name. setPreSimFcn passes the Simulink.SimulationInput object in the shape of x argument. For example:

in = in.setPreSimFcn(@myfunc, x)
where myfunc is a MATLAB function such as
function f = myfunc(x)
f ...%Compute function value with x as an input argument
You can also specify func as a function handle for an anonymous function:
in = in.setPreSimFcn(@(x) myfunction(arg1, arg2 ...))

Version History

Introduced in R2017a