Main Content

ispref

Determine if custom setting exists

Description

ispref(group,pref) returns 1 if the specified setting in the specified group exists, and 0 otherwise. If pref specifies multiple settings, ispref returns a logical array containing a 1 or 0 for each specified setting.

example

ispref(group) returns 1 if the specified group exists, and 0 otherwise.

Examples

collapse all

Add a setting called version to the mytoolbox group of settings and then check if the setting exists.

addpref('mytoolbox','version','1.0')
ispref('mytoolbox','version')
ans =
  logical
   1

Add two settings to the mytoolbox group of settings and then check if the settings exist.

addpref('mytoolbox',{'modifieddate','docpath'},{'1/9/2019','C:\mytoolbox\documentation'})
ispref('mytoolbox',{'modifieddate','docpath','hasdoc'})
ans =
  1×3 logical array
   1   1   0

MATLAB® returns a logical array containing a 1 for the modifieddate setting and a 1 for the docpath setting. The hasdoc setting does not exist and therefore the last value of the logical array is 0.

Input Arguments

collapse all

Custom setting group name, specified as a character vector or a string scalar.

Example: 'mytoolbox'

Data Types: char | string

Custom setting name, specified as a character vector, a cell array of character vectors, or a string array.

Example: 'version'

Example: {'version','modifieddate','docpath'}

Data Types: char | string

Version History

Introduced before R2006a

expand all