addGroup

Creates a new settings group inside the settings tree or inside another group.

Category: Environment and Settings > System Commands

Syntax

G = addGroup(parent, name)

Adds a group called name under parent and returns it.

G = addGroup(parent, name, 'Hidden', tf)

Also marks the group as hidden when tf is true.

Description

The settings tree stores configuration values in named groups. Product groups such as matlab already exist; a program or toolbox adds its own group so that its options live in one place. Groups can nest, and a group is reached with dot syntax: s.mygroup.sub.

Creating a group whose name is already taken in the same parent is an error. Use hasGroup to check first and removeGroup to delete it.

Input arguments

parent
The root object returned by settings, or an existing SettingsGroup.
name
Group name. It must start with a letter and contain only letters, digits and underscores.

Output arguments

G
The new matlab.settings.SettingsGroup object.

Example

Create and remove a group

s = settings;
g = addGroup(s, 'demo');
disp(class(g))
disp(hasGroup(s, 'demo'))
removeGroup(s, 'demo');
disp(hasGroup(s, 'demo'))
Output
matlab.settings.SettingsGroup
   1
   0

Notes

In MatLivre, personal values last for the current session only; they are not saved between runs as MATLAB saves them.

See also

settings hasGroup removeGroup addSetting