Main Content

Setting

Represents individual setting

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 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 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 or personal value, but it has an installation value, then the active value is the installation value.

  • If the setting has no temporary, personal, or installation 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

  • Installation 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 reverts to 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 persistent 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.

Installation 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 installation value is available from a given MATLAB installation. When modified, the value is saved to the MATLAB root. The value persists across sessions, but it does not migrate during upgrades to new versions of MATLAB.

Some settings are linked to a preference. If a setting is linked to a preference and changing the installation value changes the active value, 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 temporary value for setting
clearPersonalValueClear personal value for setting
clearInstallationValueClear installation value for setting
hasTemporaryValueDetermine whether setting has temporary value set
hasPersonalValueDetermine whether setting has personal value set
hasInstallationValue Determine whether setting has installation value set
hasFactoryValueDetermine whether setting has 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>
 InstallationValue: <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

Version History

Introduced in R2018a