Documentation

This is machine translation

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

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

setpref

Set preference

Syntax

setpref('group','pref',val)
setpref('group',{'pref1','pref2',...,'prefn'},{val1,val2,...,valn})

Description

setpref('group','pref',val) sets the preference specified by group and pref to the value val. Individual preference values can be any MATLAB® data type, including numeric types, character vectors, cell arrays, structures, and objects. Setting a preference that does not yet exist causes it to be created.

group labels a related collection of preferences. You can choose any name that is a legal variable name, and is descriptive enough to be unique, e.g., 'MathWorks_GUIDE_ApplicationPrefs'. The input argument pref identifies an individual preference in that group, and must be a legal variable name.

setpref('group',{'pref1','pref2',...,'prefn'},{val1,val2,...,valn}) sets each preference specified in the cell array of names to the corresponding value.

    Note   Preference values are persistent and maintain their values between MATLAB sessions. Where they are stored is system dependent.

Examples

Use addpref to create a preference group called mytoolbox and a preference within it called version, and then modify the contents of version using setpref:

addpref('mytoolbox','version','1.0')
getpref('mytoolbox','version')

ans =
1.0

setpref('mytoolbox','version',{'1.0','beta'})
getpref('mytoolbox','version')

ans = 
    '1.0'    'beta'

Introduced before R2006a

Was this topic helpful?