Main Content

simulink.sampletimecolors.Palette

Create custom sample time color palette for Simulink model

Since R2024b

Description

Use the simulink.sampletimecolors.Palette object to customize the color palette for sample time colors in your Simulink® model. You can specify different colors as RGB values or hexadecimal color codes and assign them to different types of sample times. To learn more about sample times, see Types of Sample Time. You can use the simulink.sampletimecolors.Palette object to apply a specific custom palette temporarily to your current MATLAB® session, or you can create and set a custom palette as the default palette for all your future MATLAB sessions.

Creation

Description

pltObj = simulink.sampletimecolors.Palette('paletteName') creates a palette object, pltObj, that you can use to customize colors for all types of sample times.

Input Arguments

expand all

Palette name, specified as a string or a character vector.

Data Types: char | string

Properties

expand all

Single Instance Sample Times

Continuous sample time color, specified as a 1-by-3 vector of RGB triplet values or as a character vector or string array of hexadecimal color code.

Fixed-in-minor step sample time color, specified as a 1-by-3 vector of RGB triplet values or as a character vector or string array of hexadecimal color code.

Color to represent constant sample time, specified as a 1-by-3 vector of RGB triplet values or as a character vector or string array of hexadecimal color code.

Color to represent multirate sample time, specified as a 1-by-3 vector of RGB triplet values or as a character vector or string array of hexadecimal color code.

Color to represent initialize event sample time, specified as a 1-by-3 vector of RGB triplet values or as a character vector or string array of hexadecimal color code.

Color to represent terminate event sample time, specified as a 1-by-3 vector of RGB triplet values or as a character vector or string array of hexadecimal color code.

Multi Instance Sample Time

Continuous variable sample time, specified as a [n-by-3 vector of RGB triplets where n is number of colors, or as a character vector or string array of hexadecimal color codes.

Discrete sample time colors, specified as a [n-by-3 vector of RGB triplets where n is number of colors, or as a character vector or string array of hexadecimal color codes.

Event sample time colors, specified as a [n-by-3 vector of RGB triplets where n is number of colors, or as a character vector or string array of hexadecimal color codes.

Reinitialize sample time colors, specified as a [n-by-3 vector of RGB triplets where n is number of colors, or as a character vector or string array of hexadecimal color codes.

Asynchronous sample time colors, specified as a [n-by-3 vector of RGB triplets where n is number of colors, or as a character vector or string array of hexadecimal color codes.

Represent aperiodic partitions colors, specified as a [n-by-3 vector of RGB triplets where n is number of colors, or as a character vector or string array of hexadecimal color codes.

Union sample time colors, specified as a [n-by-3 vector of RGB triplets where n is number of colors, or as a character vector or string array of hexadecimal color codes.

Object Functions

simulink.sampletimecolors.applyPaletteApply sample time color palette to current MATLAB session
simulink.sampletimecolors.storePaletteAdd new simulink.sampletimecolors.Palette object to preferences
simulink.sampletimecolors.getPaletteGet available simulink.sampletimecolors.Palette objects
simulink.sampletimecolors.removePaletteRemove simulink.sampletimecolors.Palette object from preferences

Examples

collapse all

  1. Create a custom color palette object with the name myFirstPalette.

    pltObj = simulink.sampletimecolors.Palette("myFirstPalette")
    
    Palette with properties:
     
                                      Name: "myFirstPalette"
                ContinuousSampleTimeColors: [0 0 0]
          FixedInMinorStepSampleTimeColors: [0.4902 0.4902 0.4902]
        ContinuousVariableSampleTimeColors: [0.4902 0.4902 0.4902]
                  DiscreteSampleTimeColors: [3x3 double]
              AsynchronousSampleTimeColors: [0.7529 0.3608 0.9843]
                  AperiodicPartitionColors: [0.7529 0.3608 0.9843]
           InitializeEventSampleTimeColors: [0.7961 0.5176 0.3647]
            TerminateEventSampleTimeColors: [0.7961 0.5176 0.3647]
                ResetEventSampleTimeColors: [0.7961 0.5176 0.3647]
         ReinitializeEventSampleTimeColors: [0.7961 0.5176 0.3647]
                  ConstantSampleTimeColors: [0.8196 0.0157 0.5451]
                 MultirateSampleTimeColors: [0.5451 0.4000 0.0235]
                     UnionSampleTimeColors: [0.4039 0.2980 0.0235]

  2. Customize colors for the discrete sample time using RGB triplet values.

    pltObj.ContinuousSampleTimeColors = [0.9 0.2 0.4];

  3. Customize colors for continuous sample time using a string array of hexadecimal codes

    pltObj.DiscreteSampleTimeColors = ["#123456", "#523467", "#204973"]
  4. Use the new custom color palette for the current MATLAB session.

    simulink.sampletimecolors.applyPalette(pltObj)
    To see the new color palette for sample times in your Simulink model, update the model diagram with Ctrl+D.

Version History

Introduced in R2024b