Main Content

addGroup

Add new factory settings group

Description

example

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.

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 that do not 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.

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

MATLAB® throws an error whenever a setting within the group is set to a nonnumeric value.

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 exists in the specified parent factory group, MATLAB displays an error.

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

Name-Value Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside quotes. You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

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, although they remain accessible.

Function to validate factory settings in group, specified as a function handle. When specified, the function is used to validate the values of all factory settings within the group that do not 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.

Introduced in R2019b