This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

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'};
    end

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

  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:

    sscexplore(simlog_ssc_dcmotor,'DC_Motor.Inertia.w')

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

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

Tip

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

Related Examples

More About