Documentation

This is machine translation

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

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

isprop

Determine if property of object

Syntax

tf = isprop(obj,'PropertyName')

Description

tf = isprop(obj,'PropertyName') returns true if the specified PropertyName is a property of object obj. Otherwise, isprop returns logical false.

If obj is an array, isprop returns a logical array the same size as obj. Each true element of tf corresponds to an element of obj that has the property, PropertyName.

    Note:   If obj is an empty object or an array of empty objects, isprop returns an empty logical array, even if PropertyName is a property of obj.

While isprop returns true if the class of an object defines a property of that name, classes can control access to property values by defining property attributes. Property access can be defined as:

  • Readable and writable

  • Read only

  • Write only

  • Accessible only to certain class methods

Therefore, isprop might indicate that a property exists, but you might not be able to access that property. For more information, see Get Information About Properties.

Examples

This example uses isprop to determine if XDataSource is a property of object h before attempting to set the property value:

h = plot(1:10);
if isprop(h,'XDataSource')
   set(h,'XDataSource','x')
else
   error(['XDataSource not a property of class ',class(h)])
end

Since XDataSource is a property of h, its value is set to 'x'.

Related Examples

See Also

|

Introduced before R2006a

Was this topic helpful?