Main Content

Simulink.sdi.setUnitSystem

Specify system of units to define signal display units in the Simulation Data Inspector

Since R2020b

    Description

    example

    Simulink.sdi.setUnitSystem(unitSystem) configures the Simulation Data Inspector to use the specified unit system to define the display units for logged and imported signals.

    The Simulation Data Inspector plots signals using the display units. The display units for a signal may differ from the stored units, which indicate units for the data as stored on disk. When you specify a system of units in the Simulation Data Inspector preferences, the Simulation Data Inspector automatically adjusts the display units for logged or imported signals that use units that are not valid in the specified system.

    example

    Simulink.sdi.setUnitSystem(unitSystem,"Overrides",overrideUnits) configures the Simulation Data Inspector to use the specified override units. Specify override units when you want a type of measurement, such as length, to use consistent units, such as m or ft, across all signals in the Simulation Data Inspector.

    Examples

    collapse all

    To specify a system of units to use for plotting signals in the Simulation Data Inspector, use the Simulink.sdi.setUnitSystem function. When you choose to display signals using the SI or US Customary unit system, the Simulation Data Inspector automatically changes the Display Units property for logged or imported signals that use units that are not part of the specified unit system. The signal data stored on disk does not change. Signals also have a Stored Units property, and the Simulation Data Inspector converts the data to plot the signal when the Stored Units and Display Units differ.

    Specify a System of Units

    By default, the Simulation Data Inspector displays signals using the units assigned to the signal during simulation or in the imported data. To facilitate analyzing multiple signals and data sets together, you can specify a system of units as a preference. The Simulation Data Inspector automatically updates the Display Units for logged or imported signals that use units that are invalid in the specified unit system. For example, a signal logged in a model using units of ft could be updated to use units of m when the system of units is specified as SI.

    Use the Simulink.sdi.setUnitSystem function to configure the Simulation Data Inspector to display signals using units in the US Customary unit system.

    Simulink.sdi.setUnitSystem('USCustomary');

    Specify Override Units

    When you want all signals that represent the same type of measurement to use the same Display Units, you can also specify override units. For example, to plot all signals that represent length using units of ft, specify ft as an override unit.

    Simulink.sdi.setUnitSystem('USCustomary','Overrides',"ft");

    Check Unit Configuration

    Use the Simulink.sdi.getUnitSystem function to check the current unit preferences configured in the Simulation Data Inspector.

    [unitSystem,overrideUnits] = Simulink.sdi.getUnitSystem
    unitSystem = 
    'USCustomary'
    
    overrideUnits = 
    "ft"
    

    Input Arguments

    collapse all

    System of units used to define signal display units, specified as 'Default', 'SI', or 'USCustomary'.

    • Default — Use signal stored units.

    • SI — Use units from the SI unit system for signal display units.

    • USCustomary — Use units from the US Customary unit system for signal display units.

    Units to override signal display units, specified as a string or string array. Specify override units when you want all signals that represent the same measurement type to use consistent units. For example, specify override units of ft to display all signals that represent length measurements using units of ft.

    Example: "Overrides",["in","lb"]

    Data Types: string

    Version History

    Introduced in R2020b