setpref
Creates a preference or changes its value.
Category: Environment and Settings > System Commands
Syntax
setpref(group, pref, val)
Stores val under pref in group, creating either if needed.
setpref(group, {pref1, pref2}, {val1, val2})
Sets several preferences at once.
Description
setpref is create-or-update: unlike addpref it does not complain when the preference exists. Read the value back with getpref.
Input arguments
group- Group name.
pref- Preference name or cell array of names.
val- Value of any type, or a cell array matching
pref.
Example
Set one and several
setpref('demoapp', 'n', 3);
setpref('demoapp', 'n', 4);
setpref('demoapp', {'a', 'b'}, {1, 'two'});
disp(getpref('demoapp', 'n'))
s = getpref('demoapp')
rmpref('demoapp');
Output
4
s = struct with fields:
n: 4
a: 1
b: 'two'