Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

in.PostSimFcn

Specify a MATLAB function to run after each simulation is complete through SimulationInput object, in

Syntax

in.PostSimFcn = @(y) myfunction(arg1, arg2...)

Description

example

in.PostSimFcn = @(y) myfunction(arg1, arg2...) runs after each simulation is complete. The Simulink.SimulationOutput object is passed as the argument y to this function. myfunction is any MATLAB® function and can be used to do the post processing on the output. To return post processed data, you must return it as values in a struct. These values are then packed into the Simulink.SimulationOutput output to replace the usual logged data.

Examples

collapse all

This example specifies a MATLAB Function through SimulationInput object to run after each simulation is complete.

Create a PostSimFcn to get the mean of the output.

function newout = postsim(out);
newout.mean = mean(out.yout);
end

Create a SimulationInput object for a model.

in = Simulink.SimulationInput('vdp');
in.PostSimFcn = @(x) postsim(x);
in = setModelParameter(in, 'SaveOutput','on');

Simulate the model.

out = sim(in)

View your result

out.mean

Input Arguments

collapse all

This is a Simulink.SimulationOutput object which is an input to myfunction.

Introduced in R2017a

Was this topic helpful?