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.


Class: sdo.SimulationTest
Package: sdo

Simulate Simulink model using simulation scenario


sim_out = sim(sim_obj)
sim_out = sim(sim_obj,Name,Value)


sim_out = sim(sim_obj) simulates a Simulink® model using the simulation scenario specified in sim_obj.

Before simulating the model, specify the parameter values and signals to log in the Parameters and LoggingInfo properties of sim_obj. The software restores the parameter values and logging settings to their original values after simulation.

sim_out = sim(sim_obj,Name,Value) specifies simulation parameters using one or more Name,Value pair arguments.

Input Arguments

expand all

Simulation scenario for a model, specified as an sdo.SimulationTest object.

Name-Value Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside single quotes (' '). You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

Example: sim_out = sim(sim_obj,'TimeOut',20) specifies the maximum simulation run time as 20 seconds.

You can specify any of the simulation parameters that the Simulink sim command accepts as Name,Value arguments. In addition, you can specify the following parameters.

expand all

Treatment of warnings as errors, specified as the comma-separated pair consisting of 'ErrorOnWarnings' and true or false. When you specify ErrorOnWarning as true, the sim command treats warnings that are generated during simulation as errors.

Data Types: logical

Restoration of settings after simulation, specified as the comma-separated pair consisting of 'RestoreSettingsAfterSim' and one of true or false. When you specify RestoreSettingsAfterSim as true, the sim command restores model parameter and model signal logging changes after the simulation ends.

Data Types: logical

Output Arguments

expand all

Simulation scenario object containing logged signal data, returned as an sdo.SimulationTest object. The logged data is stored in the LoggedData property of sim_out.


expand all

Simulate the sdoHydraulicCylinder model, and store the Pressures signal of the model.

Log the Pressures signal that is output from the first port in the Cylinder Assembly block of the model.

Pressures = Simulink.SimulationData.SignalLoggingInfo;
Pressures.BlockPath = 'sdoHydraulicCylinder/Cylinder Assembly';
Pressures.OutputPortIndex = 1;

Create a simulation scenario for the model, and specify the signal to log.

simulator = sdo.SimulationTest('sdoHydraulicCylinder');
simulator.LoggingInfo.Signals = [Pressures];

Specify parameter values for simulation.

Ac = sdo.getParameterFromModel('sdoHydraulicCylinder','Ac');
Ac.Value = 0.5;
simulator.Parameters = Ac;

Simulate the model.

sim_obj = sim(simulator);

The specified signal Pressures is logged during simulation in the LoggedData property of sim_obj. After simulation, the sim command restores model parameter and model signal logging changes. If you want to preserve your changes, specify the RestoreSettingsAfterSim argument as false.

sim_obj = sim(simulator,'RestoreSettingsAfterSim',false);
Was this topic helpful?