This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Access and Modify Settings

Settings provide a way to programmatically access and modify options for tools. For example, you can use settings to customize the appearance and behavior of the MATLAB® editor, change the code font used by MATLAB desktop tools, or change how MAT-files are saved. For documentation on individual settings, go to System Commands and select a link in Functions > Settings.

Use Settings

To access settings, use the settings function to access the root of the settings tree.

s = settings
Use dot notation to access the settings groups and settings in the tree. For example, view the list of settings groups in MATLAB.
s.matlab
ans = 

 SettingsGroup 'matlab' with properties:

    toolboxpathcache: [1×1 SettingsGroup]
         appdesigner: [1×1 SettingsGroup]
              editor: [1×1 SettingsGroup]
             general: [1×1 SettingsGroup]
               fonts: [1×1 SettingsGroup]
To get the current values for a setting, type the entire setting name using dot notation, including parent settings groups. For example, get the list of values for the maximum column width for comments in MATLAB.
s.matlab.editor.language.matlab.comments.MaxWidth
ans = 

 Setting 'matlab.editor.language.matlab.comments.MaxWidth' with properties.

       ActiveValue: 75
    TemporaryValue: <no value>
     PersonalValue: <no value>
      FactoryValue: 75
To change the active value for a setting, set either the temporary or personal value for the setting. For example, set the temporary value for the maximum column width for comments in MATLAB to 80. This temporary value will be cleared at the end of the current MATLAB session.
s.matlab.editor.language.matlab.comments.MaxWidth.TemporaryValue = 80
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

To clear the temporary or personal value for a setting, use the clearTemporaryValue and clearPersonalValue functions. For example, clear the temporary value for the maximum column width for comments in MATLAB. Use the hasTemporaryValue function to check whether the value exists before clearing it. Since the personal value for the setting is not defined, the factory value becomes the active value.

if(hasTemporaryValue(s.matlab.editor.language.matlab.comments.MaxWidth))
    clearTemporaryValue(s.matlab.editor.language.matlab.comments.MaxWidth)    
end

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

 Setting 'matlab.editor.language.matlab.comments.MaxWidth' with properties.

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

Settings Structure

Settings are organized by product in a tree-based hierarchy of settings groups. At the top of the tree is the root settings group object. Directly under the root object are the product settings groups. Each product settings group then contains its own hierarchy of settings.

The leaf nodes in the settings tree are known as the settings. Each setting has three value types.

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

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

  • Factory — The factory value is the default product setting value.

The current or active value of a setting 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 a temporary value of 12, a factory value of 10, and no personal value. In this case, the active value for MySetting is the temporary value, 12.

Settings and Preferences

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

See Also

Related Topics