Main Content

createSimulator

Create simulation object from experiment to compare measured and simulated data

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.

example

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.

example

Examples

collapse 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.

Input Arguments

collapse all

Experiment, specified as an sdo.Experiment object.

Simulation scenario, specified as an sdo.SimulationTest object.

Typically, you use the createSimulator function 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

collapse all

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.

Version History

Introduced in R2012b