Main Content

Setting

Setting object

Description

A Setting object represents an individual setting within the settings hierarchical tree.

Creation

Access individual Setting objects using the root SettingsGroup object returned by the settings function. For example, this code accesses the MaxWidth setting.

s = settings
s.matlab.editor.language.matlab.comments.MaxWidth

Properties

expand all

Current or active value, specified as a numeric array, logical array, or character array, depending on the setting.

The active value is determined as follows:

  • If the setting has a temporary value, then the active value is the temporary value.

  • If the setting has no temporary value, but it has a personal value, then the active value is the personal value.

  • If the setting has no temporary value or personal value, then the active value is the factory value.

For example, suppose you have a setting MySetting with these values:

  • Temporary value: 12

  • Personal value: no value

  • Factory value: 10

In this case, the active value for MySetting is the temporary value, 12.

Temporary setting value, specified as MATLAB data of any type except for handle types. Data containers such as cell arrays, structs, and objects that include handles are also not supported.

The temporary value is available only for the current MATLAB session and is cleared at the end of the session.

Some settings are linked to a preference. If a setting is linked to a preference, changing the temporary value for a setting temporarily changes the corresponding preference. At the end of the MATLAB session, the preference regains its original value. For more information about preferences, see Preferences.

Personal setting value, specified as MATLAB data of any type except for handle types. Data containers such as cell arrays, structs, and objects that include handles are also not supported.

The personal value is available across MATLAB sessions for an individual user. When modified, the value is saved to the preferences folder.

Some settings are linked to a preference. If a setting is linked to a preference, changing the personal value for the setting changes the corresponding preference as well. For more information about preferences, see Preferences.

This property is read-only.

Factory setting value, specified as MATLAB data of any type except for handle types. Data containers such as cell arrays, structs, and objects that include handles are also not supported.

The factory value is the default product setting. It is not modifiable. In addition, you cannot specify the factory value for a custom setting.

Object Functions

clearTemporaryValueClear the temporary value for a setting
clearPersonalValueClear the personal value for a setting
hasTemporaryValueDetermine whether the setting has a temporary value set
hasPersonalValueDetermine whether the setting has a personal value set
hasFactoryValueDetermine whether the setting has a factory value set

Examples

collapse all

View the current values for the maximum column width for comments in the Editor.

s = settings;
s.matlab.editor.language.matlab.comments.MaxWidth
ans = 
 Setting 'matlab.editor.language.matlab.comments.MaxWidth' with properties.

       ActiveValue: 80
    TemporaryValue: 80
     PersonalValue: <no value>
      FactoryValue: 75

Get and set the value for the maximum column width for comments in MATLAB.

Get the root SettingsGroup object and view the active value for the maximum column width for comments in MATLAB.

s = settings
s.matlab.editor.language.matlab.comments.MaxWidth.ActiveValue
ans =
  int32
   75

Set the temporary value for the maximum column width for comments in MATLAB.

s.matlab.editor.language.matlab.comments.MaxWidth.TemporaryValue = 80
s.matlab.editor.language.matlab.comments.MaxWidth.ActiveValue
ans =
  int32
   80
Introduced in R2018a