Preference
getpref('group','pref')
getpref('group','pref',default)
getpref('group',{'pref1','pref2',...'prefn'})
getpref('group',{'pref1',...'prefn'},{default1,...defaultn})
getpref('group')
getpref
getpref('group','pref')
returns
the value for the preference specified by group
and pref
.
It is an error to get a preference that does not exist.
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. 'ApplicationOnePrefs'
.
The input argument pref
identifies an individual
preference in that group, and must be a legal variable name.
getpref('group','pref',default)
returns
the current value if the preference specified by group
and pref
exists.
Otherwise creates the preference with the specified default value
and returns that value.
getpref('group',{'pref1','pref2',...'prefn'})
returns
a cell array containing the values for the preferences specified by group
and
the cell array of preference names. The return value is the same
size as the input cell array. It is an error if any of the preferences
do not exist.
getpref('group',{'pref1',...'prefn'},{default1,...defaultn})
returns
a cell array with the current values of the preferences specified
by group
and the cell array of preference names.
Any preference that does not exist is created with the specified
default value and returned.
getpref('group')
returns
the names and values of all preferences in the group
as
a structure.
getpref
returns all groups
and preferences as a structure.
Note Preference values are persistent and maintain their values between MATLAB® sessions. Where they are stored is system dependent. |
addpref('mytoolbox','version','1.0') getpref('mytoolbox','version') ans = 1.0
setpref('mytoolbox','version','1.0') rmpref('mytoolbox','version') getpref('mytoolbox','version','1.0'); getpref('mytoolbox','version')
ans = 1.0
The first call to getpref
adds the 'version'
preference and sets its value to the default value, 1.0
. The second call to getpref
verifies that the preference exists, and that its value is 1.0
.