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 called
ssc_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 by typing ssc_dcmotor
in the MATLAB Command Window. This example model has data logging enabled for the whole
model, with the Workspace variable name parameter set to
simlog_ssc_dcmotor
.
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_ssc_dcmotor,'DC_Motor.Inertia.w')
By default, Simscape Results Explorer plots rotational velocity in rad/s.
To switch to custom units, click the Plot options icon and then, in the Options dialog box, change
Units from
Default
to
Custom
and click OK. The rotational
velocity plot is redrawn in deg/s.
Use the function pm_getunits
to get the full list of
available units.