Contenu principal

simscape.op.create

Create operating point by extracting model or logged simulation data

Description

op = simscape.op.create(simlog,time) creates an operating point by extracting the variable targets from the simulation data log, simlog, at the simulation data time, time. If the times in simlog contain an exact match for time time, then the function extracts these values. If there is no exact match, but time is between the minimum and maximum times of simlog, then the function uses linear interpolation to determine the target values. If time is less than the minimum time, then the function extracts the first value for each variable in simlog. If time is greater than the maximum time, then the function extracts the last value in simlog.

Note

If you extract an operating point from data logged using the Simulation Data Inspector, the data does not include private data. If you create an operating point from a model or from simulation data logged to memory or disc, the output includes private data.

example

op = simscape.op.create(opSource,simPhase) creates an operating point by extracting targets from the block, subsystem, or model, opSource, and the model simulation phase, simPhase.

example

op = simscape.op.create(opSource,simPhase,cachingOption), where cachingOption is "true", creates an operating point by extracting the cached values of variable targets from models that have been previously initialized or simulated. The default for cachingOption is "false", which disables caching. Use this syntax to avoid repeatedly initializing the model if the data that you want to extract has not changed. The function returns an error if the model has not been updated, initialized, or simulated earlier in the session.

example

Examples

collapse all

Open the Permanent Magnet DC Motor example model. This model has data logging enabled. In the Configuration Parameters dialog box, the Workspace variable name parameter is simlog_PermanentMagnetDCMotor. Simulate the model to create the variable in the MATLAB workspace.

openExample("simscape/PermanentMagnetDCMotorExample")
mdl = "PermanentMagnetDCMotor";
sim(mdl)

Create an operating point named op1 from the logged simulation data at 0.1 seconds after the start of simulation.

op1 = simscape.op.create(simlog_PermanentMagnetDCMotor, 0.1)
op1 = 

  OperatingPoint with children:

  OperatingPoints:

   ChildId         Size
   ______________  ____

   'DC Motor'       1x1
   'DC Voltage'     1x1
   'ERef'           1x1
   'Load Torque'    1x1
   'MRRef Motor'    1x1
   'MRRef Torque'   1x1
   'Sensing'        1x1
   'Step Input'     1x1

Open the Permanent Magnet DC Motor example model and create an operating point named op2 by using the values from the Start simulation phase.

openExample("simscape/PermanentMagnetDCMotorExample")
mdl = "PermanentMagnetDCMotor";
op2 = simscape.op.create(mdl, "Start")
op2 = 

  OperatingPoint with children:

  OperatingPoints:

   ChildId         Size
   ______________  ____

   'DC Motor'       1x1
   'DC Voltage'     1x1
   'ERef'           1x1
   'Load Torque'    1x1
   'MRRef Motor'    1x1
   'MRRef Torque'   1x1
   'Sensing'        1x1
   'Step Input'     1x1

If you work with a large model, you can avoid initializing it repeatedly by using cached values of variable targets.

Open the Permanent Magnet DC Motor example model and simulate it:

openExample("simscape/PermanentMagnetDCMotorExample")
mdl = "PermanentMagnetDCMotor";
sim(mdl)

Create an OperatingPoint object named op3 by using the values from the Start simulation phase without reinitializing the model.

op3 = simscape.op.create(mdl + "/DC Motor", "Start", true)
op3 = 

  OperatingPoint with children:

  OperatingPoints:

   ChildId                                   Size
   ________________________________________  ____

   'Friction'                                 1x1
   'Inertia'                                  1x1
   'Rotational Electromechanical Converter'   1x1
   'Rotor Inductance'                         1x1
   'Rotor Resistance'                         1x1

Input Arguments

collapse all

Simulation log variable or node that contains the logged model simulation data, or a node of this variable, specified as a simscape.logging.Node object. You specify the name of the simulation log variable by using the Workspace variable name parameter in the Simscape pane of the Configuration Parameters dialog box.

Simulation time for data extraction, specified as a real number.

Data Types: double

Block, subsystem, or model name or identifier from which to extract operating point data, specified as a handle, model name, full path to a block or subsystem in the model, Simulink.Block object, or a valid Simulink identifier (SID).

Data Types: double | char | string

Model simulation phase from which to extract the data, specified as:

  • Start — The function initializes the root model and extracts the initial values as operating point targets for the whole model, or for the specified block or subsystem, into the operating point data. These values correspond to the Start values in the Variable Viewer.

  • Target — The function updates the root model and extracts the target values for the whole model, or for the specified block or subsystem, before initializing the model. These values correspond to the Target values in the Variable Viewer. When you select this option, the function skips the initialization step, which reduces compute time.

If the model already uses an operating point for initialization, then the function applies the initial values in that OperatingPoint to the model during both of these phases, and reflects the results in the extracted OperatingPoint, op.

Data Types: char

Option to use cached simulation data, specified as false or true. When you specify this argument as true, the function creates an operating point by extracting cached values of variable targets from a model that has been previously initialized or simulated.

Data Types: logical

Output Arguments

collapse all

Operating point in the base workspace, returned as an OperatingPoint object. The function extracts variable initialization data from the model or the logged simulation data.

Version History

Introduced in R2017b

expand all