Main Content

matlab.system.StringSet Class

Namespace: matlab.system

Set of valid character vector values

The matlab.System.StringSet class will be removed in a future release. To create properties with a finite list of values, use property validation with mustBeMember or enumerations instead. See Limit Property Values to Finite List.

Description

matlab.system.StringSet specifies a list of valid character vector values for a property. This class validates the character vector in the property and enables tab completion for the property value. A StringSet allows only predefined or customized character vectors as values for the property.

A StringSet uses two linked properties, which you must define in the same class. One is a public property that contains the current character vector value. This public property is displayed to the user. The other property is a hidden property that contains the list of all possible character vector values. This hidden property should also have the constant attribute so that the values cannot be changed by the user.

The following considerations apply when using StringSets:

  • The property that holds the current character vector can have any name.

  • The property that holds the StringSet must use the same name as the property with the suffix “Set” appended to it. This property is an instance of the matlab.system.StringSet class.

  • Valid character vectors, defined in the StringSet, must be declared using a cell array. The cell array cannot be empty nor can it have any empty character vectors. Valid character vectors must be unique and are case-sensitive.

  • The property must be set to a valid StringSet value.

The matlab.system.StringSet class is a handle class.

Examples

collapse all

Set the property, Flavor, and the StringSet property, FlavorSet in your class definition file.

properties
  Flavor = 'Chocolate'
end

properties (Hidden,Constant)
  FlavorSet = ...
    matlab.system.StringSet({'Vanilla','Chocolate'})
end

Version History

Introduced in R2011b

collapse all

R2020a: matlab.System.StringSet class will be removed

The matlab.System.StringSet class will be removed in a future release. To create properties with a finite list of values, use property validation with mustBeMember or enumerations instead. See Limit Property Values to Finite List.

Remove matlab.system.StringSet from the classdef line of your System object™.