Use Custom Units to Plot Simulation Data
Simscape™ Results Explorer has a set of default units for plotting the logged data. This example shows how you can change to a custom unit; for example, to plot rotations in degrees rather than radians.
Create a file named
ssc_customlogunits.m
and save it anywhere on the MATLAB® path. The file should contain a function calledssc_customlogunits
, which returns a cell array of the units to be used:function customUnits = ssc_customlogunits() customUnits = {'deg/s','deg'}; end
Include only the units you want to customize. For everything else, Simscape Results Explorer will use the default units.
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 the Workspace variable name parameter set to
simlog_PermanentMagnetDCMotor
.Simulate the model to log the simulation data.
Open the Simscape Results Explorer window and plot the rotational velocity of the Inertia block:
sscexplore(simlog_PermanentMagnetDCMotor,'DC_Motor.Inertia.w')
By default, Simscape Results Explorer plots rotational velocity in rad/s.
To switch to custom units, in the Simscape Results Explorer toolbar, in the Units drop-down, select
Custom
. The rotational velocity plot is redrawn in deg/s.
Tip
Use the function pm_getunits
to get the full list of
available units.
See Also
Related Examples
- Log, Navigate, and Plot Simulation Data
- Log and View Simulation Data for Selected Blocks
- Plot Simulation Data in Different Units