Main Content

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.

  1. 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'};

    Include only the units you want to customize. For everything else, Simscape Results Explorer will use the default units.

  2. Open the Permanent Magnet DC Motor example model. At the MATLAB command prompt, enter:


    This example model has data logging enabled for the whole model, with the Workspace variable name parameter set to simlog_PermanentMagnetDCMotor.

  3. Simulate the model to log the simulation data.

  4. Open the Simscape Results Explorer window and plot the rotational velocity of the Inertia block:


    By default, Simscape Results Explorer plots rotational velocity in rad/s.

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


Use the function pm_getunits to get the full list of available units.

See Also

Related Examples

More About