Main Content

addGroup

Add new factory settings group

Description

s = addGroup(parentgroup,name) adds the factory settings group name to the specified parent factory settings group and returns the new group as a FactoryGroup object. By default, factory settings groups are hidden, which means that they do not display in the parent settings group.

example

s = addGroup(___,Name,Value) specifies the factory group properties using one or more name-value pair arguments. For example, 'Hidden',false adds a group that is visible in the factory settings tree. Specify name-value pairs after all other input arguments.

example

Examples

collapse all

Create the root factory group for the toolbox mytoolbox and then add a group to the tree.

Create the root factory group mytoolbox.

myToolboxFactoryTree = matlab.settings.FactoryGroup.createToolboxGroup('mytoolbox', ...
    'Hidden',false);

Add the font group to the tree.

toolboxFontGroup = addGroup(myToolboxFactoryTree,'font','Hidden',false);

Add a settings group and specify a default validation function. This function validates the values of all settings within the group, except for settings that specify their own validation functions. This includes settings in subgroups, as long as the subgroup or settings do not specify their own validation functions.

First, create a validation function numericValidationFcn that throws an error when the input is not numeric.

function numericValidationFcn(x)
    errorMsg = 'Value must be numeric.'; 
    assert(isnumeric(x),errorMsg);
end

Create the root factory group mytoolbox and then add the group mynumericsettings to the tree. Specify the validation function numericValidationFcn. MATLAB® throws an error whenever a setting within the group is set to a nonnumeric value.

myToolboxFactoryTree = matlab.settings.FactoryGroup.createToolboxGroup('mytoolbox', ...
    'Hidden',false);
toolboxFontGroup = addGroup(myToolboxFactoryTree,'mynumericsettings','Hidden',false, ...
    'ValidationFcn',@numericValidationFcn);

Input Arguments

collapse all

Parent factory group to add the group to, specified as a FactoryGroup object. Use the matlab.settings.FactoryGroup.createToolboxGroup function to create the root factory group object.

Example: addGroup(s.mytoolbox,'newGroup')

Name of factory group to add, specified as a character vector or string. If the factory group name already exists in the specified parent factory group, MATLAB displays an error.

Example: addGroup(s.mytoolbox,'newGroup')

Name-Value Arguments

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Before R2021a, use commas to separate each name and value, and enclose Name in quotes.

Example: addGroup(parentGroup,'newGroup','Hidden',false) creates a visible factory group.

Hidden state, specified as true or false.

When set to true, the factory group, including all factory groups and factory settings within the group, do not display in the Command Window or as part of tab completion, although they remain accessible.

Function to validate factory settings in a group, specified as a function handle. When specified, the function validates the values of all factory settings within the group, except for settings that specify their own validation functions. This includes settings in subgroups, as long as the subgroup or settings do not specify their own validation functions.

The function handle must be associated with a function that accepts the potential setting value as an input argument, has no output arguments, and throws an error if the validation fails.

The function handle must point to a function on the MATLAB path. Anonymous or nested function handles are not supported.

Version History

Introduced in R2019b