Main Content

hasSetting

Determine if setting exists in settings group

Since R2019b

Description

example

hasSetting(parentgroup,name) returns 1 if the specified settings group contains a setting called name. Otherwise, hasSetting returns 0.

Examples

collapse all

Check whether a setting exists before adding it.

Use the settings function to access the root of the settings tree and then create the settings group mysettings.

s = settings;
addGroup(s,'mysettings');

Check whether the MyWorkAddress setting exists before adding it to mysettings.

if hasSetting(s.mysettings,'MyWorkAddress') == 0
    addSetting(s.mysettings,'MyWorkAddress','PersonalValue','3 Apple Hill Drive');
end
s.mysettings
ans = 
  SettingsGroup 'mysettings' with properties:
        MyWorkAddress: [1×1 Setting]

Input Arguments

collapse all

Parent settings group, specified as a SettingsGroup object. Use the settings function to access the root settings group object and all the available settings groups in the tree.

Name of the setting to check for, specified as a character vector or string scalar.

Version History

Introduced in R2019b