matlab.lang.OnOffSwitchState - Represent on and off states with logical values - MATLAB (original) (raw)

The OnOffSwitchState class enables you to form text expressions by concatenating enumeration members with character vectors or strings. For example, if an object property named Power contains an enumeration member of the OnOffSwitchState class, you can form a character array with a character vector and the property value:

a = SystemState; a.Power = true; ['The power switch is currently ' a.Power]

ans =

'The power switch is currently on'

Normally, when forming an array by concatenating character vectors or strings with enumeration members, MATLABĀ® attempts to convert the text to the class of the enumeration member. However, the OnOffSwitchState class defines specialized behavior that enables concatenation of enumeration members and text in cases where the text does not correspond to enumeration members defined by the class. In these cases, MATLAB creates an array of the same type as the text.

Here are the rules that MATLAB applies when concatenating character vectors or strings with enumeration members of the OnOffSwitchState class.