Main Content

ispref

Determine if custom preference exists

Description

example

ispref(group,pref)returns1if the specified preference in the specified group exists, and0otherwise. Ifprefspecifies multiple preferences,isprefreturns a logical array containing a1or0for each specified preference.

ispref(group)returns1if the specified group exists, and0otherwise.

Examples

collapse all

Add a preference calledversionto themytoolbox群preferences and then check if the preference exists.

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

Add two preferences to themytoolbox群preferences and then check if the preferences 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 a1for themodifieddatepreference and a1for thedocpathpreference. Thehasdocpreference does not exist and therefore the last value of the logical array is0.

Input Arguments

collapse all

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

Example:'mytoolbox'

Data Types:char|string

Custom preference 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