Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

ispref

Determine if custom preference exists

Syntax

ispref(group,pref)
ispref(group)

Description

example

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

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

Examples

collapse all

Add a preference called version to the mytoolbox group of preferences and then check if the preference exists.

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

Add two preferences to the mytoolbox group of 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 a 1 for the modifieddate and a 1 for the docpath preferences. The hasdoc preference does not exist and therefore the last value of the logical array is 0.

Input Arguments

collapse all

Preference group name, specified as a character vector or a string scalar. group must be a unique and valid variable name. For more information, see Variable Names.

Example: 'mytoolbox'

Data Types: char | string

Custom preference name, specified as a character vector, a cell array of character vectors, or a string array. pref must be a valid variable name. For more information, see Variable Names.

Example: 'version'

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

Data Types: char | string

Introduced before R2006a

Was this topic helpful?