matlab.system.StringSet class

Package: matlab.system

Set of valid string values


matlab.system.StringSet defines a list of valid string values for a property. This class validates the string in the property and enables tab completion for the property value. A StringSet allows only predefined or customized strings 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 string value. This public property is displayed to the user. The other property is a hidden property that contains the list of all possible string values. This hidden property should also have the transient attribute so its value is not saved to disk when you save the System object™.

The following considerations apply when using StringSets:

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

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

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

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


expand all

Set String Property Values

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

  Flavor = 'Chocolate';

properties (Hidden,Transient)
  FlavorSet = ...
Was this topic helpful?