Main Content

simulink.sampletimecolors.getPalette

Get available simulink.sampletimecolors.Palette objects

Since R2024b

    Description

    simulink.sampletimecolors.getPalette(option) returns one or more simulink.sampletimecolors.Palette objects based on the option specified by option.

    example

    simulink.sampletimecolors.getPalette(Name,Value) returns a single simulink.sampletimecolors.Palette object with the specified Name property.

    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 and continuous sample time using RGB values.

      mypalette.DiscreteSampleTimeColors = [0.9 0.2 0.4];
      mypalette.ContinuousSampleTimeColors = [0.7 0.5 0.3]

    3. List all existing palettes using the simulink.sampletimecolors.getPalette function with the 'all' option.

      listOfPalettes = simulink.sampletimecolors.getPalette('all')
      names = [listOfPalettes.Name]
      names =
      
        1×2 cell array
      
          {["myFirstPalette"]}    {["default (built in)"]}
      

      List the palette that is currently active using the simulink.sampletimecolors.getPalette function with the 'active' option.

      simulink.sampletimecolors.getPalette('active')
      ans = 
      
        Palette with properties:
      
                                        Name: "default (built in)"
                  ContinuousSampleTimeColors: [0 0 0]
            FixedInMinorStepSampleTimeColors: [0.4902 0.4902 0.4902]
          ContinuousVariableSampleTimeColors: [0.4902 0.4902 0.4902]
                    DiscreteSampleTimeColors: [3×3 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]
      
    4. Apply the new custom palette to the current MATLAB® session.

      simulink.sampletimecolors.applyPalette('myFirstPalette')

    Input Arguments

    collapse all

    simulink.sampletimecolors.Palette object or objects to get, specified as 'all', 'active', or 'UserDefault'.

    • all – Get a list of all the palette objects available.

    • active – Get the currently active palette object.

    • UserDefault – Get the palette object that is set as a default palette in preferences.

    Name property the simulink.sampletimecolors.Palette object that you want to return, specified as a string or a character vector.

    Example: simulink.sampletimecolors.getPalette('Name'='myFirstPalette')

    Version History

    Introduced in R2024b