Appendix B: UDD
In several places within this book, I referred to a few undocumented built-in MATLAB
functions that relate to UDD, including handle.listener and schema.prop. These functions are
not documented anywhere outside the UndocumentedMatlab.com website, so this short appen-
dix that describes them may be helpful.
This functionality, while related to Java objects as mentioned elsewhere in this book, is not
in itself Java-based. As far as I know, UDD (Unied Data Denition?) is based on C++ code.
Only one of the UDD roles is to provide wrapper functionality for Java objects within MATLAB.
In this appendix, I will only describe issues that directly relate to using Java objects — other
aspects are documented on the website.
UDD objects, also referred to as schema objects, were introduced with MATLAB 6.0 (R12)
back in 2000. UDD is a foundation technology for using handle graphics, Simulink
, Java, and
COM within MATLAB. MathWorks has consistently refused to document UDD, stating that
UDD objects are for internal use by MathWorks developers. Although there is no formal docu-
mentation, there are plenty of examples and tools to help us learn about these classes.
Since UDD classes are a foundation technology, they appear both as built-in classes and as
classes dened in m-code. We can tell whether a particular object is a UDD object by using the
undocumented built-in function classhandle, which takes one input argument (an object han-
dle) and returns a schema.class object that describes the input object. If the input object is not
a UDD object, then classhandle raises an exception. Using classhandle in code that cannot
guarantee that the input argument is a UDD object requires placing it in a try-catch block, to
handle such exceptions.
UDD and the newer, well-documented MCOS classes share many similarities. In many
respects, classhandle is analogous to the MCOS metaclass function; property and method
attributes are similar, and so on. This is not surprising, considering MCOS was developed
based on the UDD experience.
MCOS classes can either be dened as a standalone class or scoped by placing it in a pack-
age or package hierarchy. With UDD, all classes must be dened in a package. UDD packages
are not hierarchical, meaning that a UDD package may not contain other packages. UDD
classes are instantiated as packageName.className. UDD classes whose Global ag is dened
as ‘yes’ only report their className, not their package (instantiation must still be done using
This appendix is the product of joint work with Donn Shull of http://aetoolbox.com. Additional details on UDD can be
found at http://undocumentedmatlab.com/?s = UDD (or http://bit.ly/dShAuG).
K13163_Book.indb 627 11/8/2011 8:10:43 PM
Appendix B: UDD628
the package name). As far as I know, handle graphics objects are the only built-in UDD objects
that have the Global ag set to on, so they have global scope rather than package scope.
>> hFig = hg.figure % note: global hg package name is not reported
>> which hg.figure
hg.figure is a built-in method % hg.figure constructor
MCOS classes are value classes by default, but we can subclass the handle class to create
handle classes. In contrast, UDD classes are handle classes by default, but we can create value
classes by setting the Handle property to ‘off’.
The m-les that create the UDD classes supplied with MATLAB are easy to nd by search-
ing for directories containing a schema.m le. These classes include the timeseries UDD pack-
age tsdata, the user interface package uitools, and many others.
Built-in UDD classes are harder to identify, and are hidden in normal usage. For example, in
the current handle graphics version,
all HG elements are UDD objects from the hg package
that are wrapped in normal usage by a numeric handle. We can get the underlying UDD object
using the undocumented built-in handle() function:
>> hFig = handle(gcf)
>> hLine = handle(plot(1:5))
We can pass any UDD object to Java classes in MATLAB. MATLAB automatically creates
a bean adapter for the object, enabling access to the object’s methods and properties.
Any Java object created in MATLAB has an associated UDD wrapper object that is either
from the javahandle or the javahandle_withcallbacks package (the latter is invoked with the
‘CallbackProperties’ parameter, as described in Section 3.4):
>> hjButton = handle(javax.swing.JButton)
>> hjButton = handle(javax.swing.JButton, 'CallbackProperties')
Java objects’ properties and methods can be inspected using Reection. MATLAB has a
corresponding mechanism, which is accessible via the UDD classhandle:
>> chFig = classhandle(handle(gcf))
This may change in the future HG2: http://UndocumentedMatlab.com/blog/matlab-hg2/ (or http://bit.ly/chL9iK).
K13163_Book.indb 628 11/8/2011 8:10:43 PM