hasGroup
Tests whether a settings group contains a child group of a given name.
Category: Environment and Settings > System Commands
Syntax
tf = hasGroup(parent, name)
Returns true if parent has a group called name.
Description
Only direct children are checked, so hasGroup(s, 'sub') does not find a group nested two levels down. Settings are not groups: a name that belongs to a setting gives false. Use it before addGroup to avoid the error raised for a duplicate name.
Input arguments
parent- The root from
settingsor aSettingsGroup. name- Name of the child group to look for.
Output arguments
tf- Logical scalar.
Example
Check before adding
s = settings;
disp(hasGroup(s, 'matlab'))
disp(hasGroup(s, 'nothere'))
if ~hasGroup(s, 'demo')
addGroup(s, 'demo');
end
disp(hasGroup(s, 'demo'))
removeGroup(s, 'demo');
Output
1
0
1