isprop
Tests whether an object has a property of a given name.
Category: Programming > Classes
Syntax
tf = isprop(obj, 'name')
Returns true if name is a property of obj.
Description
Unlike isfield, which looks inside a struct, isprop is for objects: isprop(m, 'Count') asks whether the object m has a property called Count. It returns false for anything that is not an object, such as a number or a struct.
Input arguments
obj- An object.
'name'- Property name, as text.
Output arguments
tf- Logical scalar.
Example
Properties of a Map
m = containers.Map();
isprop(m, 'Count')
isprop(m, 'Weight')
isprop([1 2 3], 'Count')
Output
ans = logical
1
ans = logical
0
ans = logical
0