ispref

Tests whether a preference or a preference group exists.

Category: Environment and Settings > System Commands

Syntax

tf = ispref(group)

True if the group exists.

tf = ispref(group, pref)

True if the preference exists in the group; with a cell array of names it returns one logical per name.

Description

ispref never errors for a missing group or name; it just returns false. It is the safe check to run before getpref when no default makes sense.

Input arguments

group
Group name.
pref
Preference name or cell array of names.

Output arguments

tf
Logical scalar, or a logical array the size of pref.

Example

Check groups and names

setpref('demoapp', 'a', 1);
disp(ispref('demoapp'))
disp(ispref('demoapp', 'a'))
disp(ispref('demoapp', {'a', 'b'}))
rmpref('demoapp');
disp(ispref('demoapp'))
Output
   1
   1
   1   0
   0

See also

getpref setpref addpref rmpref