properties
Lists the public properties of a class or object.
Category: Programming > Classes
Syntax
properties(obj)
Displays the property names of obj.
p = properties(obj)
Returns the names as a column cell array.
p = properties('ClassName')
Does the same starting from a class name.
Description
properties reports the names a user can read through obj.Name. Properties with private or protected access and hidden properties are not listed. The order is the order of declaration in the class, with inherited properties included.
The function lists names only. To read the values use dot indexing with a dynamic name, obj.(p{1}); to see attributes such as Dependent or SetAccess, look at the property list of metaclass.
Input arguments
obj- An object, or the name of a class as text.
Output arguments
p- Column cell array of property names.
Example
Properties of a built-in class
p = properties(containers.Map)
p = 3×1 cell
{'Count' }
{'KeyType' }
{'ValueType'}
Notes
Called with no output argument, MatLivre prints the names as a cell array instead of MATLAB's list headed Properties for class .... Use an output argument to get the same result in both.