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.

createSimulator

Class: sdo.Experiment
Package: sdo

Create simulation object from experiment to compare measured and simulated data

Syntax

sim_obj = createSimulator(experiment)
sim_obj = createSimulator(experiment,sim_obj0)

Description

sim_obj = createSimulator(experiment) creates a sdo.SimulationTest object to simulate a model using the parameters and inputs specified in an experiment. You compare the simulated and measured outputs. sim_obj specifies the model stop time as the end time of the longest running experiment output signal.

sim_obj = createSimulator(experiment,sim_obj0) updates the values of the Parameters, InitialStates, Input and LoggingInfo properties of the sdo.SimulationTest object, sim_obj0. It does so using the corresponding properties specified by experiment. sim_obj0.ModelName must be the same as experiment.ModelName. You use this syntax to avoid creating a simulation scenario object (sdo.SimulationTest object) repeatedly and, instead, modify an existing simulation scenario object.

Input Arguments

experiment

Experiment, specified as an sdo.Experiment object.

sim_obj0

Simulation scenario, specified as an sdo.SimulationTest object.

Typically, you use the createSimulator method of an experiment to create sim_obj0, which returns an appropriately configured simulation scenario. You can construct sim_obj0 using the syntax sim_obj0 = sdo.SimulationTest(modelname). However, if you do so, then sim_obj0.ModelName must be the same as experiment.ModelName.

Output Arguments

sim_obj

Simulation scenario, returned as an sdo.SimulationTest object.

The properties of sim_obj are configured to simulate the model associated with experiment using the parameters, initial states and inputs defined by experiment.

When you use the syntax sim_obj = createSimulator(experiment,sim_obj0), sim_obj is the same object as sim_obj0. However, it contains the Parameters, InitialStates, and Input property values of experiment. The LoggingInfo property of sim_obj is extended to include any additional signals from experiment.OutputData.

Examples

expand all

Specify an experiment.

experiment = sdo.Experiment('sdoRCCircuit');

Create a simulation scenario for the experiment.

sim_obj = createSimulator(experiment);

Specify an experiment and a model parameter value for the experiment.

load_system('sdoRCCircuit');
p = sdo.getParameterFromModel('sdoRCCircuit','C1');
p.Value = 1e-6;
p.Free = false;
experiment = sdo.Experiment('sdoRCCircuit');
experiment.Parameters = p;

Create a simulation scenario for the experiment.

sim_obj = createSimulator(experiment);
sim_obj.Parameters.Value
ans =

   1.0000e-06

Modify the model parameter value for the experiment.

experiment.Parameters.Value = 2e-6;

Update the simulation scenario.

sim_obj = createSimulator(experiment,sim_obj);
sim_obj.Parameters.Value
ans =

   2.0000e-06

The value of the model parameter associated with sim_obj is updated.

Was this topic helpful?