Class: sdo.Experiment
Package: sdo

Create simulation object from experiment to compare measured and simulated data


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


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, specified as an sdo.Experiment object.


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


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.


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.

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);
ans =


Modify the model parameter value for the experiment.

experiment.Parameters.Value = 2e-6;

Update the simulation scenario.

sim_obj = createSimulator(experiment,sim_obj);
ans =


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

Related Examples

Was this topic helpful?