Initialize Model Using Operating Point from Logged Simulation Data - MATLAB & Simulink (original) (raw)
Main Content
This example shows how you can create an OperatingPoint
object from logged simulation data and then use this operating point to initialize the model for a subsequent simulation run.
- Open the Permanent Magnet DC Motor example model. At the MATLABĀ® command prompt, enter:
openExample('simscape/PermanentMagnetDCMotorExample')
This example model has data logging enabled for the whole model, with theWorkspace variable name parameter set tosimlog_PermanentMagnetDCMotor
. - Simulate the model to log the simulation data.
- Examine the simulation results in the Motor RPM scope window.
For the first 0.1 seconds, the motor has no external load, and the speed builds up to the no-load value. Then at 0.1 seconds, the stall torque is applied as a load to the motor shaft. - Create an operating point from logged simulation data at 0.1 seconds after the start of simulation:
op = simscape.op.create(simlog_PermanentMagnetDCMotor, 0.1)
op =
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 - Enable model initialization from operating point:
set_param(gcs,'SimscapeUseOperatingPoints','on');
This command is equivalent to selecting the Enable operating point initialization check box in the Simscape pane of the Configuration Parameters dialog box. - Specify the name of operating point:
set_param(gcs,'SimscapeOperatingPoint','op');
This command is equivalent to enteringop
in the Model operating point textbox. - Simulate the model. The simulation now starts with the full no-load speed.