You can get the value of a property and, sometimes, change the value. You also can add custom properties.
Property names are not case-sensitive. You can abbreviate them as long as the name is unambiguous.
Function | Description |
---|---|
List one or more properties and their values. | |
Set the value of one or more properties. | |
Determine if an item is a property of a COM object. | |
Add a custom property to a COM object. | |
Remove a custom property from a COM object. | |
Open the Property Inspector to display and modify property values. | |
Display the built-in property page of the control, if any. |
You can use the get
and set
functions
on more than one object at a time by creating a vector of object handles
and using these commands on the vector. To get or set values for multiple
objects, use the functional form of the get
and set
functions.
Use dot notation, for example h.propname
, on scalar
objects only.
Enumeration makes examining and changing properties easier because
each possible value for the property is assigned text to represent
it. For example, one of the values for the DefaultSaveFormat
property
in a Microsoft®
Excel® spreadsheet is xlUnicodeText
.
This text is easier to remember than a numeric value like 57.
The Property Inspector enables you to access the properties
of COM objects. To open the Property Inspector, use the inspect
function
from the MATLAB® command line or double-click the object in the MATLAB Workspace
browser.
For example, create an Excel object. Then set the DefaultFilePath
property
to an existing folder, C:\ExcelWork
.
h = actxserver('Excel.Application'); h.DefaultFilePath = 'C:\ExcelWork';
Display the properties of the object.
inspect(h)
Scroll down until you see the DefaultFilePath
property
that you just changed, C:\ExcelWork
.
Using the Property Inspector, change DefaultFilePath
once
more, this time to another existing folder, MyWorkDirectory
.
To do this, select the value at the right and type the new value.
Now go back to the MATLAB Command Window and confirm that
the DefaultFilePath
property has changed as expected.
h.DefaultFilePath
ans = C:\MyWorkDirectory
If you modify properties at the MATLAB command line, refresh
the Property Inspector window to see the change reflected there. Refresh
the Property Inspector window by reinvoking the inspect
function
on the object.
A list button next to a property value indicates that the property
accepts enumerated values. To see the values, click anywhere in the
field on the right. For example, the Cursor
property
has four enumerated values. The current value xlDefault
is
displayed in the field next to the property name.
To change the value, use the list button to display the options for that property, and then click the desired value.
You can add your own properties to an instance of a control
using the addproperty
function.
To remove custom properties from a control, use the deleteproperty
function.
Some COM objects have properties that accept input arguments.
Internally, MATLAB handles these properties as methods, which
means you use the methods
or invoke
functions
(not the get
function) to view the property.