<?xml version="1.0" encoding="UTF-8"?> <rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
><channel><title>Undocumented Matlab &#187; Hidden property</title> <atom:link href="http://undocumentedmatlab.com/blog/tag/hidden-property/feed/" rel="self" type="application/rss+xml" /><link>http://undocumentedmatlab.com</link> <description>Charting Matlab's unsupported hidden underbelly</description> <lastBuildDate>Thu, 02 Feb 2012 00:24:18 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.1.1</generator> <item><title>Types of undocumented Matlab aspects</title><link>http://undocumentedmatlab.com/blog/types-of-undocumented-matlab-aspects/</link> <comments>http://undocumentedmatlab.com/blog/types-of-undocumented-matlab-aspects/#comments</comments> <pubDate>Thu, 24 Nov 2011 18:00:36 +0000</pubDate> <dc:creator>Yair Altman</dc:creator> <category><![CDATA[High risk of breaking in future versions]]></category> <category><![CDATA[Java]]></category> <category><![CDATA[Low risk of breaking in future versions]]></category> <category><![CDATA[Medium risk of breaking in future versions]]></category> <category><![CDATA[Semi-documented feature]]></category> <category><![CDATA[Semi-documented function]]></category> <category><![CDATA[Undocumented feature]]></category> <category><![CDATA[Undocumented function]]></category> <category><![CDATA[Hidden property]]></category> <category><![CDATA[Internal component]]></category> <category><![CDATA[JMI]]></category> <category><![CDATA[Pure Matlab]]></category> <category><![CDATA[Undocumented property]]></category><guid
isPermaLink="false">http://undocumentedmatlab.com/?p=2534</guid> <description><![CDATA[This article lists the different types of undocumented/unsupported/hidden aspects in Matlab<pre> </pre>Related posts:<ol><li><a
href='http://undocumentedmatlab.com/blog/reasons-for-undocumented-matlab-aspects/' rel='bookmark' title='Reasons for undocumented Matlab aspects'>Reasons for undocumented Matlab aspects</a> <small>There are many reasons for the numerous undocumented aspects in Matlab - this article explains them....</small></li><li><a
href='http://undocumentedmatlab.com/blog/matlab-callbacks-for-java-events/' rel='bookmark' title='Matlab callbacks for Java events'>Matlab callbacks for Java events</a> <small>Events raised in Java code can be caught and handled in Matlab callback functions - this article explains how...</small></li><li><a
href='http://undocumentedmatlab.com/blog/undocumented-cursorbar-object/' rel='bookmark' title='Undocumented cursorbar object'>Undocumented cursorbar object</a> <small>Matlab's internal undocumented graphics.cursorbar object can be used to present dynamic data-tip cross-hairs...</small></li><li><a
href='http://undocumentedmatlab.com/blog/uiundo-matlab-undocumented-undo-redo-manager/' rel='bookmark' title='uiundo &#8211; Matlab&#8217;s undocumented undo/redo manager'>uiundo &#8211; Matlab&#8217;s undocumented undo/redo manager</a> <small>The built-in uiundo function provides easy yet undocumented access to Matlab's powerful undo/redo functionality. This article explains its usage....</small></li></ol><pre> </pre>]]></description> <content:encoded><![CDATA[<p>Why are there so many undocumented aspects in Matlab?</p><p>This is a great question, recently <a
target="_blank" href="http://undocumentedmatlab.com/blog/guide-customization/#comment-61578">asked</a> by a reader of this blog, so I wanted to expand on it in next week&#8217;s article. Before specifying the different reasons, let&#8217;s map the nature of undocumented aspects that we find in Matlab.</p><p>The term <i>undocumented/unsupported</i> (as opposed to <i>mis-documentated</i> or <i>deprecated</i>) actually refers to quite a large number of different types.<br
/> In the following list, the hyperlinks on the list-item titles lead to a list of corresponding articles on this website:</p><ul><li><b><a
target="_blank" href="http://undocumentedmatlab.com/blog/tag/undocumented-function/">Undocumented functions</a></b><br
/> Matlab functions which appears nowhere in the documentation, are usually built-in functions (do not have an m-file) and can only be inferred from online CSSM posts or usage within one of the Matlab m-functions installed with Matlab (the latter being the usual case). None of these functions is officially supported by MathWorks. <a
target="_blank" href="http://undocumentedmatlab.com/blog/category/mex/">MEX</a> is an important source for such functions.</p></li><li><b><a
target="_blank" href="http://undocumentedmatlab.com/blog/tag/semi-documented-function/">Semi-documented functions</a></b><br
/> Matlab functionality which exists in Matlab m-functions installed with Matlab, but have their main comment separated from the H1 comment line, thereby hiding it from normal view (via Matlab&#8217;s <i><b>help</b></i> function). The H1 comment line itself is simply a standard warning that this function is not officially supported and may change in some future version. To see the actual help comment, simply edit the function (using Matlab&#8217;s <i><b>edit</b></i> function or any text editor) and place a comment sign (%) at the empty line between the H1 comment and the actual help section. The entire help section will then onward be visible via the <i><b>help</b></i> function:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">        <span style="color: #0000FF;">function</span> <span style="color: #080;">&#91;</span>tree, container<span style="color: #080;">&#93;</span> = uitree<span style="color: #080;">&#40;</span><span style="color: #0000FF;">varargin</span><span style="color: #080;">&#41;</span>
        <span style="color: #228B22;">% WARNING: This feature is not supported in MATLAB</span>
        <span style="color: #228B22;">% and the API and functionality may change in a future release.</span>
<span style="color: #0000FF;">fix</span> =&gt;  <span style="color: #228B22;">%</span>
        <span style="color: #228B22;">% UITREE creates a uitree component with hierarchical data in a figure window.</span>
        <span style="color: #228B22;">%   UITREE creates an empty uitree object with default property values in</span>
        <span style="color: #228B22;">%   a figure window.</span>
        <span style="color: #228B22;">%...</span></pre></div></div><p>These functions are not documented in the full documentation (via Matlab&#8217;s <i><b>doc</b></i> function, or online). The odd thing is that some of these functions may appear in the category help output (for example, <i><b>help</b>(&#8216;uitools&#8217;)</i>), and in some cases may even have a fully-visible help section (e.g., <i><b>help</b>(&#8216;setptr&#8217;)</i>), but do not have any online help documentation (<i><b>docsearch</b>(&#8216;setptr&#8217;)</i> fails, and <i><b>doc</b>(&#8216;setptr&#8217;)</i> simply displays the readable help text).</p><p>All these functions are officially unsupported by MathWorks, even when having a readable help section. The rule of thumb appears to be that a Matlab function is supported only if it has online documentation. Note, however, that in some rare cases a documentation discrepancy may be due to a MathWorks documentation error, not to unsupportability&#8230;</p></li><li><b><a
target="_blank" href="http://undocumentedmatlab.com/blog/tag/undocumented-function/">Helper functions</a></b><br
/> Many fully-supported Matlab functions use helper functions that have a specific use in the main (documented) function(s).  Often, these helper functions are tightly-coupled to their documented parents and are useless as stand-alone functions. But quite a few of them have quite useful stand-alone use, as I&#8217;ve already shown in some past articles.</p></li><li><b><a
target="_blank" href="http://undocumentedmatlab.com/blog/tag/undocumented-feature/">Undocumented features</a> and <a
target="_blank" href="http://undocumentedmatlab.com/blog/tag/undocumented-property/">properties</a></b><br
/> Features of otherwise-documented Matlab functions, which appear nowhere in the official documentation. You guessed it – these are also not supported by MathWorks&#8230; Like undocumented functions, you can only infer such features by the occasional CSSM post or a reference somewhere in Matlab&#8217;s m-code.</p></li><li><b><a
target="_blank" href="http://undocumentedmatlab.com/blog/tag/semi-documented-feature/">Semi-documented features</a></b><br
/> Features of otherwise-documented Matlab functions, which are documented in a separate section beneath the main help section, and nowhere else (not in the full doc not the online documentation). If you did not know in advance that these features existed, you could only learn of them by manually looking at Matlab&#8217;s m-files (which is what I do in most cases&#8230;).</p></li><li><b><a
target="_blank" href="http://undocumentedmatlab.com/blog/tag/undocumented-property/">Undocumented properties</a></b><br
/> Many Matlab objects have internal properties, which can be retrieved (via Matlab&#8217;s <i><b>get</b></i> function) and/or set (via the <i><b>set</b></i> function) programmatically. All these properties are fully documented. Many objects also possess hidden properties, some of which are very interesting and useful, but which are undocumented and (oh yes) unsupported. Like undocumented features, they can only be inferred from CSSM or existing code. In a recent <a
target="_blank" href="http://undocumentedmatlab.com/blog/getundoc-get-undocumented-object-properties/">article</a> I described my <i><b>getundoc</b></i> utility, which lists these undocumented properties of specified objects.</p></li><li><b><a
target="_blank" href="http://undocumentedmatlab.com/blog/tag/internal-component/">Internal Matlab classes</a></b><br
/> Matlab uses a vast array of specialized Java classes to handle everything from algorithms to GUI. These classes are (of course) undocumented/unsupported. They can often be accessed directly from the Matlab Command Window or user m-files. GUI classes can be inferred by inspecting the figure frame&#8217;s Java components, and non-GUI classes can often be inferred from references in Matlab&#8217;s m-files.</p></li><li><b><a
target="_blank" href="http://undocumentedmatlab.com/blog/tag/JMI">Matlab-Java integration</a></b><br
/> Matlab&#8217;s GUI interface, as well as the Java-to-Matlab interface (JMI) is fully undocumented and unsupported. In addition to JMI, there are other mechanisms to run Matlab code from within Java (namely JMI, COM and DDE) &#8211; these are all unsupported and by-and-large undocumented.</p></li><li><b><a
target="_blank" href="http://undocumentedmatlab.com/?s=UDD">Matlab&#8217;s UDD mechanism</a></b><br
/> UDD (Unified Data Definition?) is used extensively in Matlab as the internal object-oriented mechanism for describing object properties and functionalities. We can use UDD for a wide variety of uses. UDD was described in a series of articles here in early 2011.</li></ul><p>Next week I will list the reasons that cause MathWorks to decide whether a particular feature or property should be documented or not.</p><p><pre> </pre>Related posts:<ol><li><a
href='http://undocumentedmatlab.com/blog/reasons-for-undocumented-matlab-aspects/' rel='bookmark' title='Reasons for undocumented Matlab aspects'>Reasons for undocumented Matlab aspects</a> <small>There are many reasons for the numerous undocumented aspects in Matlab - this article explains them....</small></li><li><a
href='http://undocumentedmatlab.com/blog/matlab-callbacks-for-java-events/' rel='bookmark' title='Matlab callbacks for Java events'>Matlab callbacks for Java events</a> <small>Events raised in Java code can be caught and handled in Matlab callback functions - this article explains how...</small></li><li><a
href='http://undocumentedmatlab.com/blog/undocumented-cursorbar-object/' rel='bookmark' title='Undocumented cursorbar object'>Undocumented cursorbar object</a> <small>Matlab's internal undocumented graphics.cursorbar object can be used to present dynamic data-tip cross-hairs...</small></li><li><a
href='http://undocumentedmatlab.com/blog/uiundo-matlab-undocumented-undo-redo-manager/' rel='bookmark' title='uiundo &#8211; Matlab&#8217;s undocumented undo/redo manager'>uiundo &#8211; Matlab&#8217;s undocumented undo/redo manager</a> <small>The built-in uiundo function provides easy yet undocumented access to Matlab's powerful undo/redo functionality. This article explains its usage....</small></li></ol></p><pre> </pre>]]></content:encoded> <wfw:commentRss>http://undocumentedmatlab.com/blog/types-of-undocumented-matlab-aspects/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Determining axes zoom state</title><link>http://undocumentedmatlab.com/blog/determining-axes-zoom-state/</link> <comments>http://undocumentedmatlab.com/blog/determining-axes-zoom-state/#comments</comments> <pubDate>Thu, 10 Nov 2011 18:45:38 +0000</pubDate> <dc:creator>Yair Altman</dc:creator> <category><![CDATA[Handle graphics]]></category> <category><![CDATA[Hidden property]]></category> <category><![CDATA[Medium risk of breaking in future versions]]></category> <category><![CDATA[Stock Matlab function]]></category> <category><![CDATA[Undocumented feature]]></category> <category><![CDATA[Pure Matlab]]></category><guid
isPermaLink="false">http://undocumentedmatlab.com/?p=2529</guid> <description><![CDATA[The information of whether or not an axes is zoomed or panned can easily be inferred from an internal undocumented object.<pre> </pre>Related posts:<ol><li><a
href='http://undocumentedmatlab.com/blog/axes-looseinset-property/' rel='bookmark' title='Axes LooseInset property'>Axes LooseInset property</a> <small>Matlab plot axes have an undocumented LooseInset property that sets empty margins around the axes, and can be set to provide a tighter fit of the axes to their surroundings....</small></li><li><a
href='http://undocumentedmatlab.com/blog/tri-state-checkbox/' rel='bookmark' title='Tri-state checkbox'>Tri-state checkbox</a> <small>Matlab checkboxes can easily be made to support tri-state functionality....</small></li><li><a
href='http://undocumentedmatlab.com/blog/recovering-previous-editor-state/' rel='bookmark' title='Recovering previous editor state'>Recovering previous editor state</a> <small>Recovering the previous state of the Matlab editor and its loaded documents is possible using a built-in backup config file. ...</small></li><li><a
href='http://undocumentedmatlab.com/blog/plot-liminclude-properties/' rel='bookmark' title='Plot LimInclude properties'>Plot LimInclude properties</a> <small>The plot objects' XLimInclude, YLimInclude, ZLimInclude, ALimInclude and CLimInclude properties are an important feature, that has both functional and performance implications....</small></li></ol><pre> </pre>]]></description> <content:encoded><![CDATA[<p>A couple of days ago, a reader of Matlab&#8217;s official Desktop blog <a
target="_blank" rel="nofollow" href="http://blogs.mathworks.com/desktop/2007/12/10/focused-on-zooming/#comment-8204">asked</a> whether it is possible to determine if an axes has been zoomed or not.</p><p>I have encountered this question myself some time ago, when I tried to customize a radar plot: The grid in radar plots does not automatically re-draw when the plot is zoomed, as in regular rectangular plots. Instead, the radial (angle) and circular (range) grid lines are statically painted when the plot is created, and remain fixed when the plot is zoomed or panned. Therefore, if we zoom in on a small-enough plot segment, we will not see any grid lines at all. It would be beneficial to repaint the grid-lines upon every zoom and pan event. I will not dive into the details today, but the important thing for today&#8217;s article is that the algorithm needed to know whether or not the axes is currently zoomed or not.</p><p>The official response is that this information is not readily available. We could of course store the axes limits somewhere and then compare them to the current limits in run-time. This will cause complications if the plotted data (and thereby the axes limits) change automatically during program use, even without any zooming/panning. It is also problematic if the user resets the zoom limits (as Jiro has correctly <a
target="_blank" rel="nofollow" href="http://blogs.mathworks.com/desktop/2007/12/10/focused-on-zooming/#comment-8206">pointed out</a>).</p><p>Today I&#8217;ll highlight another possible solution, that perhaps not many Matlab users are familiar with: Apparently, whenever zooming or panning occur, a hidden <b>ApplicationData</b> object is automatically added to the affected axes, with information about the original axes meta-data: limits, aspect ratio, camera info and view angles. This object is also automatically updated whenever we use <b><i>zoom reset</i></b> to reset the zoom limits.</p><p>So basically, all we have to do in run-time is to compare our current access limits with the stored info: if they are the same (or if the app-data object is missing) then the plot is unzoomed and unpanned; otherwise it is. So simple.</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">origInfo = <span style="color: #0000FF;">getappdata</span><span style="color: #080;">&#40;</span><span style="color: #0000FF;">gca</span>, <span style="color:#A020F0;">'matlab_graphics_resetplotview'</span><span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">if</span> <span style="color: #0000FF;">isempty</span><span style="color: #080;">&#40;</span>origInfo<span style="color: #080;">&#41;</span>
   isZoomed = <span style="color: #0000FF;">false</span>;
<span style="color: #0000FF;">elseif</span> isequal<span style="color: #080;">&#40;</span><span style="color: #0000FF;">get</span><span style="color: #080;">&#40;</span><span style="color: #0000FF;">gca</span>,<span style="color:#A020F0;">'XLim'</span><span style="color: #080;">&#41;</span>, origInfo.<span style="color: #0000FF;">XLim</span><span style="color: #080;">&#41;</span> <span style="color: #F0F;">&amp;&amp;</span> <span style="color: #F0F;">...</span>
       <span style="">isequal</span><span style="color: #080;">&#40;</span><span style="color: #0000FF;">get</span><span style="color: #080;">&#40;</span><span style="color: #0000FF;">gca</span>,<span style="color:#A020F0;">'YLim'</span><span style="color: #080;">&#41;</span>, origInfo.<span style="color: #0000FF;">YLim</span><span style="color: #080;">&#41;</span> <span style="color: #F0F;">&amp;&amp;</span> <span style="color: #F0F;">...</span>
       <span style="">isequal</span><span style="color: #080;">&#40;</span><span style="color: #0000FF;">get</span><span style="color: #080;">&#40;</span><span style="color: #0000FF;">gca</span>,<span style="color:#A020F0;">'ZLim'</span><span style="color: #080;">&#41;</span>, origInfo.<span style="color: #0000FF;">ZLim</span><span style="color: #080;">&#41;</span>
   isZoomed = <span style="color: #0000FF;">false</span>;
<span style="color: #0000FF;">else</span>
   isZoomed = <span style="color: #0000FF;">true</span>;
<span style="color: #0000FF;">end</span></pre></div></div><p>This still does not solve the problem of limit changes when the plot data is changed, but it may perhaps be a bit easier to use than manually storing the limits before plotting. (And yes, of course the if-else statement above could be made a one-liner logical construct, but I think this way is more readable).</p><p>Zooming and panning add some additional data to <b>ApplicationData</b>, and also use/modify some other hidden properties of the axes handle (use the <a
target="_blank" href="http://undocumentedmatlab.com/blog/getundoc-get-undocumented-object-properties/"><b><i>getundoc</i></b> function</a> to see them). If you use one of them for any useful purpose, please report your usage in a <a
href="http://undocumentedmatlab.com/blog/determining-axes-zoom-state/#Respond">comment below</a>.</p><p><pre> </pre>Related posts:<ol><li><a
href='http://undocumentedmatlab.com/blog/axes-looseinset-property/' rel='bookmark' title='Axes LooseInset property'>Axes LooseInset property</a> <small>Matlab plot axes have an undocumented LooseInset property that sets empty margins around the axes, and can be set to provide a tighter fit of the axes to their surroundings....</small></li><li><a
href='http://undocumentedmatlab.com/blog/tri-state-checkbox/' rel='bookmark' title='Tri-state checkbox'>Tri-state checkbox</a> <small>Matlab checkboxes can easily be made to support tri-state functionality....</small></li><li><a
href='http://undocumentedmatlab.com/blog/recovering-previous-editor-state/' rel='bookmark' title='Recovering previous editor state'>Recovering previous editor state</a> <small>Recovering the previous state of the Matlab editor and its loaded documents is possible using a built-in backup config file. ...</small></li><li><a
href='http://undocumentedmatlab.com/blog/plot-liminclude-properties/' rel='bookmark' title='Plot LimInclude properties'>Plot LimInclude properties</a> <small>The plot objects' XLimInclude, YLimInclude, ZLimInclude, ALimInclude and CLimInclude properties are an important feature, that has both functional and performance implications....</small></li></ol></p><pre> </pre>]]></content:encoded> <wfw:commentRss>http://undocumentedmatlab.com/blog/determining-axes-zoom-state/feed/</wfw:commentRss> <slash:comments>2</slash:comments> </item> <item><title>getundoc &#8211; get undocumented object properties</title><link>http://undocumentedmatlab.com/blog/getundoc-get-undocumented-object-properties/</link> <comments>http://undocumentedmatlab.com/blog/getundoc-get-undocumented-object-properties/#comments</comments> <pubDate>Wed, 21 Sep 2011 19:00:16 +0000</pubDate> <dc:creator>Yair Altman</dc:creator> <category><![CDATA[Handle graphics]]></category> <category><![CDATA[Hidden property]]></category> <category><![CDATA[Medium risk of breaking in future versions]]></category> <category><![CDATA[Stock Matlab function]]></category> <category><![CDATA[Undocumented feature]]></category> <category><![CDATA[HG2]]></category> <category><![CDATA[Pure Matlab]]></category> <category><![CDATA[schema.prop]]></category> <category><![CDATA[Undocumented property]]></category><guid
isPermaLink="false">http://undocumentedmatlab.com/?p=2437</guid> <description><![CDATA[getundoc is a very simple utility that displays the hidden (undocumented) properties of a specified handle object.<pre> </pre>Related posts:<ol><li><a
href='http://undocumentedmatlab.com/blog/undocumented-cursorbar-object/' rel='bookmark' title='Undocumented cursorbar object'>Undocumented cursorbar object</a> <small>Matlab's internal undocumented graphics.cursorbar object can be used to present dynamic data-tip cross-hairs...</small></li><li><a
href='http://undocumentedmatlab.com/blog/udd-properties/' rel='bookmark' title='UDD Properties'>UDD Properties</a> <small>UDD provides a very convenient way to add customizable properties to existing Matlab object handles...</small></li><li><a
href='http://undocumentedmatlab.com/blog/plot-liminclude-properties/' rel='bookmark' title='Plot LimInclude properties'>Plot LimInclude properties</a> <small>The plot objects' XLimInclude, YLimInclude, ZLimInclude, ALimInclude and CLimInclude properties are an important feature, that has both functional and performance implications....</small></li><li><a
href='http://undocumentedmatlab.com/blog/displaying-hidden-handle-properties/' rel='bookmark' title='Displaying hidden handle properties'>Displaying hidden handle properties</a> <small>I present two ways of checking undocumented hidden properties in Matlab Handle Graphics (HG) handles...</small></li></ol><pre> </pre>]]></description> <content:encoded><![CDATA[<p>Last week, I <a
target="_blank" href="http://undocumentedmatlab.com/blog/controlling-plot-data-tips/#Properties">presented</a> the list of undocumented properties available in Matlab&#8217;s cursor mode and data-tip objects. Over the past two years, I had posted <a
target="_blank" href="http://undocumentedmatlab.com/blog/category/hidden-property/">quite a few other articles</a> on this website that used such undocumented properties. So today I will show exactly how such properties can be discovered.</p><p>Hidden properties are object properties that for some reason or other MathWorks has decided not to expose to the general public. They can still be used by Matlab users, just like any other regular property. But if you use the built-in <i><b>get</b></i> and <i><b>set</b></i> functions to list the object&#8217;s properties, you will not find the hidden properties listed. You need to know the hidden properties&#8217; exact name in order to use them. Which is where today&#8217;s post can help, by showing you how to list these hidden properties. I <a
target="_blank" href="http://undocumentedmatlab.com/blog/displaying-hidden-handle-properties/">wrote about this</a> a couple of years ago, and today&#8217;s article will expand on that original post.</p><p>Hidden properties are by their very nature undocumented and not officially supported. For this reason, you should take extra care when relying on them in your code. They could change functionality or even be removed without prior notice in any future Matlab release. Still, some of these properties enable very important functionality, as I have often shown on this website.</p><h3 id="HideUndocumented">HideUndocumented</h3><p>There are two distinct manners by which undocumented properties can be seen in Matlab. The simplest was <a
target="_blank" rel="nofollow" href="http://www.mathworks.com/matlabcentral/newsreader/view_thread/1183#2277">reported</a> by Hans Olsson all the way back in 1997, in one of the very earliest posts on the CSSM newsgroup (there is no earlier public report, as far as I could tell). Since then, this method was mentioned in about a dozen <a
target="_blank" rel="nofollow" href="http://www.mathworks.com/matlabcentral/newsreader/search_results?dur=all&#038;page=1&#038;query=hideundocumented&#038;search=+Go+&#038;search_string=hideundocumented&#038;search_submit=cssm">other CSSM posts</a>.</p><p>By setting the Matlab root (handle 0)&#8217;s <b>HideUndocumented</b> property to &#8216;off&#8217; (default=&#8217;on&#8217;), subsequent calls to the built-in <i><b>get</b></i> and <i><b>set</b></i> functions list the hidden properties in addition to the regular ones. Note that <b>HideUndocumented</b> is itself a hidden property, which is why Hans&#8217; post is so important &#8211; he presented us with the loose end that then enabled us to untangle the hidden properties in any other HG object.</p><p>Here is a simple example, showing <b>HideUndocumented</b>&#8216;s effect on the root (handle 0) object handle itself (hidden properties are highlighted):</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;"><span style="color: #228B22;">% Display only regular properties</span>
&gt;&gt; <span style="color: #0000FF;">get</span><span style="color: #080;">&#40;</span><span style="color: #33f;">0</span><span style="color: #080;">&#41;</span>
	CallbackObject = <span style="color: #080;">&#91;</span><span style="color: #080;">&#93;</span>
	CommandWindowSize = <span style="color: #080;">&#91;</span><span style="color: #33f;">86</span> <span style="color: #33f;">51</span><span style="color: #080;">&#93;</span>
	CurrentFigure = <span style="color: #080;">&#91;</span><span style="color: #080;">&#93;</span>
	<span style="color: #0000FF;">Diary</span> = off
	DiaryFile = <span style="color: #0000FF;">diary</span>
	<span style="color: #0000FF;">Echo</span> = off
	FixedWidthFontName = Courier New
	<span style="color: #0000FF;">Format</span> = longG
	FormatSpacing = compact
	Language = he_il
	MonitorPositions = <span style="color: #080;">&#91;</span> <span style="color: #080;">&#40;</span><span style="color: #33f;">2</span> by <span style="color: #33f;">4</span><span style="color: #080;">&#41;</span> <span style="color: #0000FF;">double</span> array<span style="color: #080;">&#93;</span>
	<span style="color: #0000FF;">More</span> = off
	PointerLocation = <span style="color: #080;">&#91;</span><span style="color: #33f;">1084</span> <span style="color: #33f;">590</span><span style="color: #080;">&#93;</span>
	RecursionLimit = <span style="color: #080;">&#91;</span><span style="color: #33f;">500</span><span style="color: #080;">&#93;</span>
	ScreenDepth = <span style="color: #080;">&#91;</span><span style="color: #33f;">32</span><span style="color: #080;">&#93;</span>
	ScreenPixelsPerInch = <span style="color: #080;">&#91;</span><span style="color: #33f;">96</span><span style="color: #080;">&#93;</span>
	ScreenSize = <span style="color: #080;">&#91;</span><span style="color: #33f;">1</span> <span style="color: #33f;">1</span> <span style="color: #33f;">1440</span> <span style="color: #33f;">900</span><span style="color: #080;">&#93;</span>
	ShowHiddenHandles = off
	Units = pixels
&nbsp;
	BeingDeleted = off
	ButtonDownFcn = 
	Children = <span style="color: #080;">&#91;</span><span style="color: #080;">&#93;</span>
	Clipping = on
	CreateFcn = 
	DeleteFcn = 
	BusyAction = queue
	HandleVisibility = on
	HitTest = on
	Interruptible = on
	Parent = <span style="color: #080;">&#91;</span><span style="color: #080;">&#93;</span>
	Selected = off
	SelectionHighlight = on
	Tag = 
	<span style="color: #0000FF;">Type</span> = root
	<span style="color: #0000FF;">UIContextMenu</span> = <span style="color: #080;">&#91;</span><span style="color: #080;">&#93;</span>
	UserData = <span style="color: #080;">&#91;</span><span style="color: #080;">&#93;</span>
	Visible = on
&nbsp;
<span style="color: #228B22;">% Display ALL properties (including hidden ones, which are highlighted below)</span>
&gt;&gt; <span style="color: #0000FF;">set</span><span style="color: #080;">&#40;</span><span style="color: #33f;">0</span>,<span style="color:#A020F0;">'HideUndocumented'</span>,<span style="color:#A020F0;">'off'</span><span style="color: #080;">&#41;</span>
&gt;&gt; <span style="color: #0000FF;">get</span><span style="color: #080;">&#40;</span><span style="color: #33f;">0</span><span style="color: #080;">&#41;</span>
<span style="display:block;background-color: #ffc;">	BlackAndWhite = off</span>	CallbackObject = <span style="color: #080;">&#91;</span><span style="color: #080;">&#93;</span>
	CommandWindowSize = <span style="color: #080;">&#91;</span><span style="color: #33f;">86</span> <span style="color: #33f;">51</span><span style="color: #080;">&#93;</span>
	CurrentFigure = <span style="color: #080;">&#91;</span><span style="color: #080;">&#93;</span>
	<span style="color: #0000FF;">Diary</span> = off
	DiaryFile = <span style="color: #0000FF;">diary</span>
	<span style="color: #0000FF;">Echo</span> = off
<span style="display:block;background-color: #ffc;">	ErrorMessage = <span style="color: #080;">&#91;</span> <span style="color: #080;">&#40;</span><span style="color: #33f;">1</span> by <span style="color: #33f;">79</span><span style="color: #080;">&#41;</span> <span style="color: #0000FF;">char</span> array<span style="color: #080;">&#93;</span></span>	FixedWidthFontName = Courier New
	<span style="color: #0000FF;">Format</span> = longG
	FormatSpacing = compact
<span style="display:block;background-color: #ffc;">	HideUndocumented = off</span>	Language = he_il
	MonitorPositions = <span style="color: #080;">&#91;</span> <span style="color: #080;">&#40;</span><span style="color: #33f;">2</span> by <span style="color: #33f;">4</span><span style="color: #080;">&#41;</span> <span style="color: #0000FF;">double</span> array<span style="color: #080;">&#93;</span>
	<span style="color: #0000FF;">More</span> = off
	PointerLocation = <span style="color: #080;">&#91;</span><span style="color: #33f;">1022</span> <span style="color: #33f;">82</span><span style="color: #080;">&#93;</span>
<span style="display:block;background-color: #ffc;">	PointerWindow = <span style="color: #080;">&#91;</span><span style="color: #33f;">0</span><span style="color: #080;">&#93;</span></span>	RecursionLimit = <span style="color: #080;">&#91;</span><span style="color: #33f;">500</span><span style="color: #080;">&#93;</span>
	ScreenDepth = <span style="color: #080;">&#91;</span><span style="color: #33f;">32</span><span style="color: #080;">&#93;</span>
	ScreenPixelsPerInch = <span style="color: #080;">&#91;</span><span style="color: #33f;">96</span><span style="color: #080;">&#93;</span>
	ScreenSize = <span style="color: #080;">&#91;</span><span style="color: #33f;">1</span> <span style="color: #33f;">1</span> <span style="color: #33f;">1440</span> <span style="color: #33f;">900</span><span style="color: #080;">&#93;</span>
	ShowHiddenHandles = off
	Units = pixels
<span style="display:block;background-color: #ffc;">	AutomaticFileUpdates = on</span>&nbsp;
	BeingDeleted = off
<span style="display:block;background-color: #ffc;">	PixelBounds = <span style="color: #080;">&#91;</span><span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span><span style="color: #080;">&#93;</span></span>	ButtonDownFcn = 
	Children = <span style="color: #080;">&#91;</span><span style="color: #080;">&#93;</span>
	Clipping = on
	CreateFcn = 
	DeleteFcn = 
	BusyAction = queue
	HandleVisibility = on
<span style="display:block;background-color: #ffc;">	HelpTopicKey = </span>	HitTest = on
	Interruptible = on
	Parent = <span style="color: #080;">&#91;</span><span style="color: #080;">&#93;</span>
	Selected = off
	SelectionHighlight = on
<span style="display:block;background-color: #ffc;">	Serializable = on</span>	Tag = 
	<span style="color: #0000FF;">Type</span> = root
	<span style="color: #0000FF;">UIContextMenu</span> = <span style="color: #080;">&#91;</span><span style="color: #080;">&#93;</span>
	UserData = <span style="color: #080;">&#91;</span><span style="color: #080;">&#93;</span>
<span style="display:block;background-color: #ffc;">	ApplicationData = <span style="color: #080;">&#91;</span> <span style="color: #080;">&#40;</span><span style="color: #33f;">1</span> by <span style="color: #33f;">1</span><span style="color: #080;">&#41;</span> <span style="color: #0000FF;">struct</span> array<span style="color: #080;">&#93;</span></span><span style="display:block;background-color: #ffc;">	Behavior = <span style="color: #080;">&#91;</span> <span style="color: #080;">&#40;</span><span style="color: #33f;">1</span> by <span style="color: #33f;">1</span><span style="color: #080;">&#41;</span> <span style="color: #0000FF;">struct</span> array<span style="color: #080;">&#93;</span></span>	Visible = on
<span style="display:block;background-color: #ffc;">	XLimInclude = on</span><span style="display:block;background-color: #ffc;">	YLimInclude = on</span><span style="display:block;background-color: #ffc;">	ZLimInclude = on</span><span style="display:block;background-color: #ffc;">	CLimInclude = on</span><span style="display:block;background-color: #ffc;">	ALimInclude = on</span><span style="display:block;background-color: #ffc;">	IncludeRenderer = on</span></pre></div></div><h3 id="schema">Property definitions</h3><p>An entirely different mechanism uses the <i><b>schema.prop</b></i> definitions that were <a
target="_blank" href="http://undocumentedmatlab.com/blog/udd-properties/">presented here</a> by Donn Scull at the beginning of 2011. The idea is to get the object&#8217;s <i><b>classhandle</b></i> reference, from it to get the list of properties definitions, and for each property look at its <b>Visible</b> meta-property: hidden properties will simply have <b>Visible</b>=&#8217;off&#8217;, whereas regular properties will have &#8216;on&#8217;.</p><p>It turns out that there is not always a full correspondence between these two mechanism. I can&#8217;t remember specific examples, and perhaps these were fixed in the latest Matlab releases. It doesn&#8217;t matter, because merging the list of hidden properties reported by these two methods is always safe to do. Which is exactly what my <i><b>getundoc</b></i> utility does:</p><h3 id="getundoc">getundoc utility</h3><p>The <i><b>getundoc</b></i> utility is based on another utility by the same name, posted by <a
target="_blank" rel="nofollow" href="http://www.mathworks.com/matlabcentral/fileexchange/authors/31831">Duane Hanselman</a> to the Matlab File Exchange in 2006 (Duane has elected to remove all his submissions from FEX a year or two ago, but that&#8217;s an entirely separate [and extremely heated] topic for a different discussion). Duane&#8217;s original <i><b>getundoc</b></i> utility relied only on the first (<b>HideUndocumented</b>) mechanism.</p><p>I have since expanded this utility to include support for the second mechanism, as well as support for the upcoming HG2 (see below). The updated <i><b>getundoc</b></i> is now <a
target="_blank" rel="nofollow" href="http://www.mathworks.com/matlabcentral/fileexchange/32934-getundoc-get-undocumented-object-properties">available for download</a> on the File Exchange. Since it&#8217;s a very short utility, I will digress from my norm and simply present its code, in its present form, here:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;"><span style="color: #0000FF;">function</span> c = getundoc<span style="color: #080;">&#40;</span>arg<span style="color: #080;">&#41;</span>
<span style="color: #228B22;">%GETUNDOC Get Undocumented Object Properties.</span>
<span style="color: #228B22;">% GETUNDOC('OBJECT') or GETUNDOC(H) returns a structure of</span>
<span style="color: #228B22;">% undocumented properties (names &amp; values) for the object having handle</span>
<span style="color: #228B22;">% H or indentified by the string 'OBJECT'.</span>
<span style="color: #228B22;">%</span>
<span style="color: #228B22;">% For example, GETUNDOC('axes') or GETUNDOC(gca) returns undocumented</span>
<span style="color: #228B22;">% property names and values for the axes object.</span>
&nbsp;
<span style="color: #228B22;">% Extension of Duane Hanselman's original utility (which is no longer</span>
<span style="color: #228B22;">% available on the File Exchange):</span>
<span style="color: #228B22;">% D.C. Hanselman, University of Maine, Orono, ME 04469</span>
<span style="color: #228B22;">% MasteringMatlab@yahoo.com</span>
<span style="color: #228B22;">% Mastering MATLAB 7</span>
<span style="color: #228B22;">% 2006-01-06</span>
&nbsp;
<span style="color: #0000FF;">if</span> <span style="color: #0000FF;">nargin</span>~=<span style="color: #33f;">1</span>
   <span style="color: #0000FF;">error</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'One Input Required.'</span><span style="color: #080;">&#41;</span>
<span style="color: #0000FF;">end</span>
<span style="color: #0000FF;">if</span> <span style="color: #0000FF;">ischar</span><span style="color: #080;">&#40;</span>arg<span style="color: #080;">&#41;</span> <span style="color: #228B22;">% GETUNDOC('OBJECT')</span>
   <span style="color: #0000FF;">switch</span> <span style="color: #0000FF;">lower</span><span style="color: #080;">&#40;</span>arg<span style="color: #080;">&#41;</span>
   <span style="color: #0000FF;">case</span> <span style="color:#A020F0;">'root'</span>                                                       <span style="color: #228B22;">% root</span>
      h=<span style="color: #33f;">0</span>;
      hf=<span style="color: #33f;">0</span>;
   <span style="color: #0000FF;">case</span> <span style="color:#A020F0;">'figure'</span>                                                   <span style="color: #228B22;">% figure</span>
      h=<span style="color: #0000FF;">figure</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'Visible'</span>,<span style="color:#A020F0;">'off'</span><span style="color: #080;">&#41;</span>;
      hf=h;
   <span style="color: #0000FF;">otherwise</span>                          <span style="color: #228B22;">% some other string name of an object</span>
      hf=<span style="color: #0000FF;">figure</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'Visible'</span>,<span style="color:#A020F0;">'off'</span><span style="color: #080;">&#41;</span>;
      object=str2func<span style="color: #080;">&#40;</span>arg<span style="color: #080;">&#41;</span>;
      <span style="color: #0000FF;">try</span>
         h=object<span style="color: #080;">&#40;</span><span style="color:#A020F0;">'Parent'</span>,hf,<span style="color:#A020F0;">'Visible'</span>,<span style="color:#A020F0;">'off'</span><span style="color: #080;">&#41;</span>;
      <span style="color: #0000FF;">catch</span>
         <span style="color: #0000FF;">error</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'Unknown Object Type String Provided.'</span><span style="color: #080;">&#41;</span>         
      <span style="color: #0000FF;">end</span>
   <span style="color: #0000FF;">end</span>
<span style="color: #0000FF;">elseif</span> <span style="color: #0000FF;">ishandle</span><span style="color: #080;">&#40;</span>arg<span style="color: #080;">&#41;</span> <span style="color: #228B22;">% GETUNDOC(H)</span>
   h=arg;
   hf=<span style="color: #33f;">0</span>;
<span style="color: #0000FF;">else</span>
   <span style="color: #0000FF;">error</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'Unknown Object Handle Provided.'</span><span style="color: #080;">&#41;</span>
<span style="color: #0000FF;">end</span>
&nbsp;
wstate=<span style="color: #0000FF;">warning</span>;
<span style="color: #0000FF;">warning</span> off                                      <span style="color: #228B22;">% supress warnings about obsolete properties</span>
<span style="color: #0000FF;">try</span> <span style="color: #0000FF;">set</span><span style="color: #080;">&#40;</span><span style="color: #33f;">0</span>,<span style="color:#A020F0;">'HideUndocumented'</span>,<span style="color:#A020F0;">'off'</span><span style="color: #080;">&#41;</span>; <span style="color: #0000FF;">catch</span>; <span style="color: #0000FF;">end</span>  <span style="color: #228B22;">% Fails in HG2</span>
undocfnames=<span style="color: #0000FF;">fieldnames</span><span style="color: #080;">&#40;</span><span style="color: #0000FF;">get</span><span style="color: #080;">&#40;</span>h<span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>;                  <span style="color: #228B22;">% get props including undocumented</span>
<span style="color: #0000FF;">try</span> <span style="color: #0000FF;">set</span><span style="color: #080;">&#40;</span><span style="color: #33f;">0</span>,<span style="color:#A020F0;">'HideUndocumented'</span>,<span style="color:#A020F0;">'on'</span><span style="color: #080;">&#41;</span>; <span style="color: #0000FF;">catch</span>; <span style="color: #0000FF;">end</span>   <span style="color: #228B22;">% Fails in HG2</span>
docfnames=<span style="color: #0000FF;">fieldnames</span><span style="color: #080;">&#40;</span><span style="color: #0000FF;">get</span><span style="color: #080;">&#40;</span>h<span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>;                    <span style="color: #228B22;">% get props excluding undocumented</span>
&nbsp;
<span style="color: #228B22;">% Yair 18/3/2010 - add a few more undocs:</span>
<span style="color: #0000FF;">try</span>
    <span style="color: #228B22;">% This works in HG1</span>
    props = <span style="color: #0000FF;">get</span><span style="color: #080;">&#40;</span>classhandle<span style="color: #080;">&#40;</span>handle<span style="color: #080;">&#40;</span>h<span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>,<span style="color:#A020F0;">'properties'</span><span style="color: #080;">&#41;</span>;
    undocfnames = <span style="color: #080;">&#91;</span>undocfnames; <span style="color: #0000FF;">get</span><span style="color: #080;">&#40;</span>props<span style="color: #080;">&#40;</span><span style="color: #0000FF;">strcmp</span><span style="color: #080;">&#40;</span><span style="color: #0000FF;">get</span><span style="color: #080;">&#40;</span>props,<span style="color:#A020F0;">'Visible'</span><span style="color: #080;">&#41;</span>,<span style="color:#A020F0;">'off'</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>,<span style="color:#A020F0;">'Name'</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#93;</span>;
<span style="color: #0000FF;">catch</span>
    <span style="color: #228B22;">% Yair 18/9/2011: In HG2, the above fails, so use the following workaround:</span>
    <span style="color: #0000FF;">try</span>
        prop = <span style="color: #0000FF;">findprop</span><span style="color: #080;">&#40;</span>handle<span style="color: #080;">&#40;</span>h<span style="color: #080;">&#41;</span>,undocfnames<span style="color: #080;">&#123;</span><span style="color: #33f;">1</span><span style="color: #080;">&#125;</span><span style="color: #080;">&#41;</span>;
        props = prop.<span style="">DefiningClass</span>.<span style="">PropertyList</span>;
        undocfnames = <span style="color: #080;">&#91;</span>undocfnames; <span style="color: #080;">&#123;</span>props.<span style="">Name</span><span style="color: #080;">&#125;</span>'<span style="color: #080;">&#93;</span>;   <span style="color: #228B22;">% {props([props.Hidden]).Name}</span>
    <span style="color: #0000FF;">catch</span>
        <span style="color: #228B22;">% ignore...</span>
    <span style="color: #0000FF;">end</span>
<span style="color: #0000FF;">end</span>
&nbsp;
c = <span style="color: #0000FF;">setdiff</span><span style="color: #080;">&#40;</span>undocfnames,docfnames<span style="color: #080;">&#41;</span>;      <span style="color: #228B22;">% extract undocumented</span>
&nbsp;
<span style="color: #228B22;">% Get the values in struct format, if relevant</span>
<span style="color: #0000FF;">if</span> ~<span style="color: #0000FF;">isempty</span><span style="color: #080;">&#40;</span>c<span style="color: #080;">&#41;</span>
  s = <span style="color: #0000FF;">struct</span>;
  <span style="color: #0000FF;">for</span> fieldIdx = <span style="color: #33f;">1</span> <span style="color: #F0F;">:</span> <span style="color: #0000FF;">length</span><span style="color: #080;">&#40;</span>c<span style="color: #080;">&#41;</span>
      <span style="color: #0000FF;">try</span>
          fieldName = c<span style="color: #080;">&#123;</span>fieldIdx<span style="color: #080;">&#125;</span>;
          s.<span style="color: #080;">&#40;</span>fieldName<span style="color: #080;">&#41;</span> = <span style="color: #0000FF;">get</span><span style="color: #080;">&#40;</span>h,fieldName<span style="color: #080;">&#41;</span>;
      <span style="color: #0000FF;">catch</span>
          s.<span style="color: #080;">&#40;</span>fieldName<span style="color: #080;">&#41;</span> = <span style="color:#A020F0;">'???'</span>;
      <span style="color: #0000FF;">end</span>
  <span style="color: #0000FF;">end</span>
  c = s;
<span style="color: #0000FF;">end</span>
<span style="color: #228B22;">% Yair end</span>
&nbsp;
<span style="color: #0000FF;">if</span> hf~=<span style="color: #33f;">0</span>                     <span style="color: #228B22;">% delete hidden figure holding selected object</span>
   <span style="color: #0000FF;">delete</span><span style="color: #080;">&#40;</span>hf<span style="color: #080;">&#41;</span>
<span style="color: #0000FF;">end</span>
<span style="color: #0000FF;">warning</span><span style="color: #080;">&#40;</span>wstate<span style="color: #080;">&#41;</span></pre></div></div><p>Usage of this utility is extremely simple:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">&gt;&gt; getundoc<span style="color: #080;">&#40;</span><span style="color: #33f;">0</span><span style="color: #080;">&#41;</span>
<span style="color: #0000FF;">ans</span> = 
             ALimInclude<span style="color: #F0F;">:</span> <span style="color:#A020F0;">'on'</span>
         ApplicationData<span style="color: #F0F;">:</span> <span style="color: #080;">&#91;</span>1x1 <span style="color: #0000FF;">struct</span><span style="color: #080;">&#93;</span>
    AutomaticFileUpdates<span style="color: #F0F;">:</span> <span style="color:#A020F0;">'on'</span>
                Behavior<span style="color: #F0F;">:</span> <span style="color: #080;">&#91;</span>1x1 <span style="color: #0000FF;">struct</span><span style="color: #080;">&#93;</span>
           BlackAndWhite<span style="color: #F0F;">:</span> <span style="color:#A020F0;">'off'</span>
             CLimInclude<span style="color: #F0F;">:</span> <span style="color:#A020F0;">'on'</span>
            ErrorMessage<span style="color: #F0F;">:</span> <span style="color: #080;">&#91;</span>1x79 <span style="color: #0000FF;">char</span><span style="color: #080;">&#93;</span>
            HelpTopicKey<span style="color: #F0F;">:</span> <span style="color:#A020F0;">''</span>
        HideUndocumented<span style="color: #F0F;">:</span> <span style="color:#A020F0;">'on'</span>
         IncludeRenderer<span style="color: #F0F;">:</span> <span style="color:#A020F0;">'on'</span>
             PixelBounds<span style="color: #F0F;">:</span> <span style="color: #080;">&#91;</span><span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span><span style="color: #080;">&#93;</span>
           PointerWindow<span style="color: #F0F;">:</span> <span style="color: #33f;">0</span>
            Serializable<span style="color: #F0F;">:</span> <span style="color:#A020F0;">'on'</span>
             XLimInclude<span style="color: #F0F;">:</span> <span style="color:#A020F0;">'on'</span>
             YLimInclude<span style="color: #F0F;">:</span> <span style="color:#A020F0;">'on'</span>
             ZLimInclude<span style="color: #F0F;">:</span> <span style="color:#A020F0;">'on'</span>
&nbsp;
&gt;&gt; getundoc<span style="color: #080;">&#40;</span><span style="color: #0000FF;">gcf</span><span style="color: #080;">&#41;</span>
<span style="color: #0000FF;">ans</span> = 
               ALimInclude<span style="color: #F0F;">:</span> <span style="color:#A020F0;">'on'</span>
    ActivePositionProperty<span style="color: #F0F;">:</span> <span style="color:#A020F0;">'position'</span>
           ApplicationData<span style="color: #F0F;">:</span> <span style="color: #080;">&#91;</span>1x1 <span style="color: #0000FF;">struct</span><span style="color: #080;">&#93;</span>
              BackingStore<span style="color: #F0F;">:</span> <span style="color:#A020F0;">'on'</span>
                  Behavior<span style="color: #F0F;">:</span> <span style="color: #080;">&#91;</span>1x1 <span style="color: #0000FF;">struct</span><span style="color: #080;">&#93;</span>
               CLimInclude<span style="color: #F0F;">:</span> <span style="color:#A020F0;">'on'</span>
                CurrentKey<span style="color: #F0F;">:</span> <span style="color:#A020F0;">''</span>
           CurrentModifier<span style="color: #F0F;">:</span> <span style="color: #080;">&#123;</span>1x0 <span style="color: #0000FF;">cell</span><span style="color: #080;">&#125;</span>
                 Dithermap<span style="color: #F0F;">:</span> <span style="color: #080;">&#91;</span>64x3 <span style="color: #0000FF;">double</span><span style="color: #080;">&#93;</span>
             DithermapMode<span style="color: #F0F;">:</span> <span style="color:#A020F0;">'manual'</span>
              DoubleBuffer<span style="color: #F0F;">:</span> <span style="color:#A020F0;">'on'</span>
            ExportTemplate<span style="color: #F0F;">:</span> <span style="color: #080;">&#91;</span><span style="color: #080;">&#93;</span>
               FixedColors<span style="color: #F0F;">:</span> <span style="color: #080;">&#91;</span>3x3 <span style="color: #0000FF;">double</span><span style="color: #080;">&#93;</span>
                   HelpFcn<span style="color: #F0F;">:</span> <span style="color:#A020F0;">''</span>
              HelpTopicKey<span style="color: #F0F;">:</span> <span style="color:#A020F0;">''</span>
              HelpTopicMap<span style="color: #F0F;">:</span> <span style="color:#A020F0;">''</span>
           IncludeRenderer<span style="color: #F0F;">:</span> <span style="color:#A020F0;">'on'</span>
                 JavaFrame<span style="color: #F0F;">:</span> <span style="color: #080;">&#91;</span>1x1 com.<span style="">mathworks</span>.<span style="">hg</span>.<span style="">peer</span>.<span style="">HG1FigurePeer</span><span style="color: #080;">&#93;</span>
               MinColormap<span style="color: #F0F;">:</span> <span style="color: #33f;">64</span>
             OuterPosition<span style="color: #F0F;">:</span> <span style="color: #080;">&#91;</span><span style="color: #33f;">436</span> <span style="color: #33f;">374</span> <span style="color: #33f;">568</span> <span style="color: #33f;">502</span><span style="color: #080;">&#93;</span>
               PixelBounds<span style="color: #F0F;">:</span> <span style="color: #080;">&#91;</span><span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">560</span> <span style="color: #33f;">420</span><span style="color: #080;">&#93;</span>
             PrintTemplate<span style="color: #F0F;">:</span> <span style="color: #080;">&#91;</span><span style="color: #080;">&#93;</span>
              Serializable<span style="color: #F0F;">:</span> <span style="color:#A020F0;">'on'</span>
                    UseHG2<span style="color: #F0F;">:</span> <span style="color:#A020F0;">'off'</span>
                WaitStatus<span style="color: #F0F;">:</span> <span style="color: #080;">&#91;</span><span style="color: #080;">&#93;</span>
               XLimInclude<span style="color: #F0F;">:</span> <span style="color:#A020F0;">'on'</span>
               YLimInclude<span style="color: #F0F;">:</span> <span style="color:#A020F0;">'on'</span>
               ZLimInclude<span style="color: #F0F;">:</span> <span style="color:#A020F0;">'on'</span></pre></div></div><h3 id="HG2">Fixes for HG2</h3><p>Unfortunately, in the new <a
target="_blank" href="http://undocumentedmatlab.com/blog/matlab-hg2/">HG2</a> (which is still not in production, but we must be prepared, mustn&#8217;t we?), the original mechanism above (<b>HideUndocumented</b>) fails completely (there is no such property in the new <code>matlab.ui.root</code> object), whereas the second mechanism (UDD property defs) needs to be modified: Apparently, <i><b>classhandle</b></i> fails for HG2 object handles. Instead, we use the workaround of using <i><b>findprop</b></i> to get the property definition for any regular property, then get its parent (the requested class definition), and then down again to list all available properties. Note that in HG2, the relevant meta-property is <b>Hidden</b> which holds logical (<b><i>true/false</i></b>) values, as opposed to <b>Visible</b> and &#8216;off&#8217;/'on&#8217; values for HG1 above.</p><p>All of these fixes are now incorporated in the <i><b>getundoc</b></i> code that is listed above.</p><p>When comparing the list of hidden properties in the existing HG1 and the new HG2, we see many interesting differences. And yes: the figure&#8217;s <a
target="_blank" href="http://undocumentedmatlab.com/blog/minimize-maximize-figure-window/#JavaFrame"><b>JavaFrame</b></a> property was indeed removed in HG2. Bummer! (don&#8217;t worry &#8211; there are several workarounds up my sleeve&#8230;)</p><p>Do you have any favorite hidden property that you use in your code? If so, please tell us about it in a comment <a
href="http://undocumentedmatlab.com/blog/getundoc-get-undocumented-object-properties/#respond">below</a>.</p><p>p.s. &#8211; For all the numerous good people telling me about <a
target="_blank" href="http://undocumentedmatlab.com/blog/cprintf-display-formatted-color-text-in-command-window/"><i><b>cprintf</b></i></a> &#8211; Yes: I am aware that the latest R2011b release has broken <i><b>cprintf</b></i>&#8216;s functionality. I plan to release a workaround sometime soon, when I have some spare time. I&#8217;ll keep everybody posted of course. Please be patient. (if you can&#8217;t wait, you can always <a
target="_blank" href="http://undocumentedmatlab.com/consulting/">hire me</a> to fix it sooner; otherwise I need to give priority to my paying clients&#8230;)</p><p><pre> </pre>Related posts:<ol><li><a
href='http://undocumentedmatlab.com/blog/undocumented-cursorbar-object/' rel='bookmark' title='Undocumented cursorbar object'>Undocumented cursorbar object</a> <small>Matlab's internal undocumented graphics.cursorbar object can be used to present dynamic data-tip cross-hairs...</small></li><li><a
href='http://undocumentedmatlab.com/blog/udd-properties/' rel='bookmark' title='UDD Properties'>UDD Properties</a> <small>UDD provides a very convenient way to add customizable properties to existing Matlab object handles...</small></li><li><a
href='http://undocumentedmatlab.com/blog/plot-liminclude-properties/' rel='bookmark' title='Plot LimInclude properties'>Plot LimInclude properties</a> <small>The plot objects' XLimInclude, YLimInclude, ZLimInclude, ALimInclude and CLimInclude properties are an important feature, that has both functional and performance implications....</small></li><li><a
href='http://undocumentedmatlab.com/blog/displaying-hidden-handle-properties/' rel='bookmark' title='Displaying hidden handle properties'>Displaying hidden handle properties</a> <small>I present two ways of checking undocumented hidden properties in Matlab Handle Graphics (HG) handles...</small></li></ol></p><pre> </pre>]]></content:encoded> <wfw:commentRss>http://undocumentedmatlab.com/blog/getundoc-get-undocumented-object-properties/feed/</wfw:commentRss> <slash:comments>3</slash:comments> </item> <item><title>Controlling plot data-tips</title><link>http://undocumentedmatlab.com/blog/controlling-plot-data-tips/</link> <comments>http://undocumentedmatlab.com/blog/controlling-plot-data-tips/#comments</comments> <pubDate>Wed, 14 Sep 2011 20:42:40 +0000</pubDate> <dc:creator>Yair Altman</dc:creator> <category><![CDATA[Handle graphics]]></category> <category><![CDATA[Hidden property]]></category> <category><![CDATA[Medium risk of breaking in future versions]]></category> <category><![CDATA[Stock Matlab function]]></category> <category><![CDATA[Undocumented feature]]></category> <category><![CDATA[Undocumented function]]></category> <category><![CDATA[modemanager]]></category> <category><![CDATA[Pure Matlab]]></category> <category><![CDATA[Undocumented property]]></category><guid
isPermaLink="false">http://undocumentedmatlab.com/?p=2432</guid> <description><![CDATA[Data-tips are an extremely useful plotting tool that can easily be controlled programmatically.<pre> </pre>Related posts:<ol><li><a
href='http://undocumentedmatlab.com/blog/accessing-plot-brushed-data/' rel='bookmark' title='Accessing plot brushed data'>Accessing plot brushed data</a> <small>Plot data brushing can be accessed programmatically using very simple pure-Matlab code...</small></li><li><a
href='http://undocumentedmatlab.com/blog/plot-linesmoothing-property/' rel='bookmark' title='Plot LineSmoothing property'>Plot LineSmoothing property</a> <small>LineSmoothing is a hidden and undocumented plot line property that creates anti-aliased (smooth unpixelized) lines in Matlab plots...</small></li><li><a
href='http://undocumentedmatlab.com/blog/plot-liminclude-properties/' rel='bookmark' title='Plot LimInclude properties'>Plot LimInclude properties</a> <small>The plot objects' XLimInclude, YLimInclude, ZLimInclude, ALimInclude and CLimInclude properties are an important feature, that has both functional and performance implications....</small></li><li><a
href='http://undocumentedmatlab.com/blog/com-activex-tips/' rel='bookmark' title='COM/ActiveX tips &amp; tricks'>COM/ActiveX tips &#038; tricks</a> <small>This article describes several little-known tips useful for COM / ActiveX programming in Matlab...</small></li></ol><pre> </pre>]]></description> <content:encoded><![CDATA[<p>Plot <a
target="_blank" rel="nofollow" href="http://www.mathworks.com/help/techdoc/creating_plots/f4-44221.html">data tips</a> are a great visualization aid for Matlab plots. They enable users to interactively click on a plot location and see a tool-tip that contains the clicked location&#8217;s coordinates. The displayed tooltip text is even customizable using documented properties of the <i><b><a
target="_blank" rel="nofollow" href="http://www.mathworks.com/help/techdoc/ref/datacursormode.html">datacursormode</a></b></i> object.</p><p><center><div
class="wp-caption aligncenter" style="width: 441px"><img
alt="plot data tips" src="http://UndocumentedMatlab.com/images/datatips.png" title="plot data tips" width="431" /><p
class="wp-caption-text">plot data tips</p></div></center></p><p>A client has recently asked me to automatically display an attached data-tip to the last data point of a plotted time series of values. The idea was to immediately see what the latest value of the data series is.</p><p>Unfortunately, the official documentation clearly says that:</p><blockquote><p>You place data tips only by clicking data objects on graphs. You cannot place them programmatically (by executing code to position a data cursor).</p></blockquote><p>Well, this has never stopped us before, has it?</p><h3 id="Creating">Creating new data tips</h3><p>Under the hood, data tips use a data-cursor mode, which shares many similarities in behavior and programming code with the other plot modes (zoom, pan, <a
target="_blank" href="http://undocumentedmatlab.com/blog/accessing-plot-brushed-data/">data-brushing</a>, etc.). At any one time, only a single such mode can be active in any figure window (this is a known limitation of the design). The code itself it actually quite complex and handles numerous edge-cases. Understanding it by simply reading the code (under %matlabroot%\toolbox\matlab\graphics\) is actually pretty difficult. A much easier way to understand the programming flow is to liberally distribute breakpoints (start in <i>datacursormode.m</i>) and interactively activate the functionality, then debug the code step-by-step.</p><p>Luckily, it turns out that the code to create a new data-tip is actually quite simple: first get the data-cursor mode object, then create a new data tip using the mode&#8217;s <i>createDatatip()</i> method, update some data-tip properties and finally update the data-tip&#8217;s position:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;"><span style="color: #228B22;">% First plot the data</span>
hLine = <span style="color: #0000FF;">plot</span><span style="color: #080;">&#40;</span>xdata, ydata<span style="color: #080;">&#41;</span>;
&nbsp;
<span style="color: #228B22;">% First get the figure's data-cursor mode, activate it, and set some of its properties</span>
cursorMode = datacursormode<span style="color: #080;">&#40;</span><span style="color: #0000FF;">gcf</span><span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">set</span><span style="color: #080;">&#40;</span>cursorMode, <span style="color:#A020F0;">'enable'</span>,<span style="color:#A020F0;">'on'</span>, <span style="color:#A020F0;">'UpdateFcn'</span>,@setDataTipTxt, <span style="color:#A020F0;">'NewDataCursorOnClick'</span>,<span style="color: #0000FF;">false</span><span style="color: #080;">&#41;</span>;
<span style="color: #228B22;">% Note: the optional @setDataTipTxt is used to customize the data-tip's appearance</span>
&nbsp;
<span style="color: #228B22;">% Note: the following code was adapted from %matlabroot%\toolbox\matlab\graphics\datacursormode.m</span>
<span style="color: #228B22;">% Create a new data tip</span>
hTarget = handle<span style="color: #080;">&#40;</span>hLine<span style="color: #080;">&#41;</span>;
hDatatip = cursorMode.<span style="">createDatatip</span><span style="color: #080;">&#40;</span>hTarget<span style="color: #080;">&#41;</span>;
&nbsp;
<span style="color: #228B22;">% Create a copy of the context menu for the datatip:</span>
<span style="color: #0000FF;">set</span><span style="color: #080;">&#40;</span>hDatatip,<span style="color:#A020F0;">'UIContextMenu'</span>,<span style="color: #0000FF;">get</span><span style="color: #080;">&#40;</span>cursorMode,<span style="color:#A020F0;">'UIContextMenu'</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">set</span><span style="color: #080;">&#40;</span>hDatatip,<span style="color:#A020F0;">'HandleVisibility'</span>,<span style="color:#A020F0;">'off'</span><span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">set</span><span style="color: #080;">&#40;</span>hDatatip,<span style="color:#A020F0;">'Host'</span>,hTarget<span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">set</span><span style="color: #080;">&#40;</span>hDatatip,<span style="color:#A020F0;">'ViewStyle'</span>,<span style="color:#A020F0;">'datatip'</span><span style="color: #080;">&#41;</span>;
&nbsp;
<span style="color: #228B22;">% Set the data-tip orientation to top-right rather than auto</span>
<span style="color: #0000FF;">set</span><span style="color: #080;">&#40;</span>hDatatip,<span style="color:#A020F0;">'OrientationMode'</span>,<span style="color:#A020F0;">'manual'</span><span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">set</span><span style="color: #080;">&#40;</span>hDatatip,<span style="color:#A020F0;">'Orientation'</span>,<span style="color:#A020F0;">'top-right'</span><span style="color: #080;">&#41;</span>;
&nbsp;
<span style="color: #228B22;">% Update the datatip marker appearance</span>
<span style="color: #0000FF;">set</span><span style="color: #080;">&#40;</span>hDatatip, <span style="color:#A020F0;">'MarkerSize'</span>,<span style="color: #33f;">5</span>, <span style="color:#A020F0;">'MarkerFaceColor'</span>,<span style="color:#A020F0;">'none'</span>, <span style="color: #F0F;">...</span>
              <span style="color:#A020F0;">'MarkerEdgeColor'</span>,<span style="color:#A020F0;">'k'</span>, <span style="color:#A020F0;">'Marker'</span>,<span style="color:#A020F0;">'o'</span>, <span style="color:#A020F0;">'HitTest'</span>,<span style="color:#A020F0;">'off'</span><span style="color: #080;">&#41;</span>;
&nbsp;
<span style="color: #228B22;">% Move the datatip to the right-most data vertex point</span>
position = <span style="color: #080;">&#91;</span>xdata<span style="color: #080;">&#40;</span><span style="color: #0000FF;">end</span><span style="color: #080;">&#41;</span>,ydata<span style="color: #080;">&#40;</span><span style="color: #0000FF;">end</span><span style="color: #080;">&#41;</span>,<span style="color: #33f;">1</span>; xdata<span style="color: #080;">&#40;</span><span style="color: #0000FF;">end</span><span style="color: #080;">&#41;</span>,ydata<span style="color: #080;">&#40;</span><span style="color: #0000FF;">end</span><span style="color: #080;">&#41;</span>,-<span style="color: #33f;">1</span><span style="color: #080;">&#93;</span>;
update<span style="color: #080;">&#40;</span>hDatatip, position<span style="color: #080;">&#41;</span>;</pre></div></div><h3 id="Updating">Updating an existing data tip</h3><p>To modify the appearance of a data-tip, we first need to get access to the <code>hDatatip</code> object that we created earlier, either programmatically, or interactively (or both). Since we can access pre-stored handles only of programmatically-created (not interactively-created) data-tips, we need to use a different method. There are actually two ways to do this:</p><p>The basic way is to search the relevant axes for objects that have <b>Tag</b>=&#8217;DataTipMarker&#8217;. For each data-tip, we will get two such handles: one for the marker (<b>Type</b>=&#8217;line&#8217;) and the other for the text box tooltip (<b>Type</b>=&#8217;text&#8217;). We can use these to update (for example) the marker size, color and style; and the text&#8217;s font, border and colors.</p><p>A better way is to access the <code>graphics.datatip</code> object itself. This can be done using two hidden properties of the <i><b>datacursormode</b></i> object:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;"><span style="color: #228B22;">% Get the list of all data-tips in the current figure</span>
&gt;&gt; cursorMode = datacursormode<span style="color: #080;">&#40;</span><span style="color: #0000FF;">gcf</span><span style="color: #080;">&#41;</span>
cursorMode =
	graphics.<span style="">datacursormanager</span>
&nbsp;
&gt;&gt; cursorMode.<span style="">DataCursors</span>
<span style="color: #0000FF;">ans</span> =
	graphics.<span style="">datatip</span><span style="color: #F0F;">:</span> <span style="color: #33f;">2</span>-by-<span style="color: #33f;">1</span>
&nbsp;
&gt;&gt; cursorMode.<span style="">CurrentDataCursor</span>
<span style="color: #0000FF;">ans</span> =
	graphics.<span style="">datatip</span>
&nbsp;
&gt;&gt; cursorMode.<span style="">CurrentDataCursor</span>.<span style="color: #0000FF;">get</span>
            Annotation<span style="color: #F0F;">:</span> <span style="color: #080;">&#91;</span>1x1 hg.<span style="">Annotation</span><span style="color: #080;">&#93;</span>
           DisplayName<span style="color: #F0F;">:</span> <span style="color:#A020F0;">''</span>
           HitTestArea<span style="color: #F0F;">:</span> <span style="color:#A020F0;">'off'</span>
          BeingDeleted<span style="color: #F0F;">:</span> <span style="color:#A020F0;">'off'</span>
         ButtonDownFcn<span style="color: #F0F;">:</span> <span style="color: #080;">&#91;</span><span style="color: #080;">&#93;</span>
              Children<span style="color: #F0F;">:</span> <span style="color: #080;">&#91;</span>2x1 <span style="color: #0000FF;">double</span><span style="color: #080;">&#93;</span>
              Clipping<span style="color: #F0F;">:</span> <span style="color:#A020F0;">'on'</span>
             CreateFcn<span style="color: #F0F;">:</span> <span style="color: #080;">&#91;</span><span style="color: #080;">&#93;</span>
             DeleteFcn<span style="color: #F0F;">:</span> <span style="color: #080;">&#91;</span><span style="color: #080;">&#93;</span>
            BusyAction<span style="color: #F0F;">:</span> <span style="color:#A020F0;">'queue'</span>
      HandleVisibility<span style="color: #F0F;">:</span> <span style="color:#A020F0;">'off'</span>
               HitTest<span style="color: #F0F;">:</span> <span style="color:#A020F0;">'off'</span>
         Interruptible<span style="color: #F0F;">:</span> <span style="color:#A020F0;">'on'</span>
                Parent<span style="color: #F0F;">:</span> <span style="color: #33f;">492.005493164063</span>
    SelectionHighlight<span style="color: #F0F;">:</span> <span style="color:#A020F0;">'on'</span>
                   Tag<span style="color: #F0F;">:</span> <span style="color:#A020F0;">''</span>
                  <span style="color: #0000FF;">Type</span><span style="color: #F0F;">:</span> <span style="color:#A020F0;">'hggroup'</span>
              UserData<span style="color: #F0F;">:</span> <span style="color: #080;">&#91;</span><span style="color: #080;">&#93;</span>
              Selected<span style="color: #F0F;">:</span> <span style="color:#A020F0;">'off'</span>
             FontAngle<span style="color: #F0F;">:</span> <span style="color:#A020F0;">'normal'</span>
              FontName<span style="color: #F0F;">:</span> <span style="color:#A020F0;">'Helvetica'</span>
              FontSize<span style="color: #F0F;">:</span> <span style="color: #33f;">8</span>
             FontUnits<span style="color: #F0F;">:</span> <span style="color:#A020F0;">'points'</span>
            FontWeight<span style="color: #F0F;">:</span> <span style="color:#A020F0;">'normal'</span>
             EdgeColor<span style="color: #F0F;">:</span> <span style="color: #080;">&#91;</span><span style="color: #33f;">0.8</span> <span style="color: #33f;">0.8</span> <span style="color: #33f;">0.8</span><span style="color: #080;">&#93;</span>
       BackgroundColor<span style="color: #F0F;">:</span> <span style="color: #080;">&#91;</span><span style="color: #33f;">1</span> <span style="color: #33f;">1</span> <span style="color: #33f;">0.933333333333333</span><span style="color: #080;">&#93;</span>
             TextColor<span style="color: #F0F;">:</span> <span style="color: #080;">&#91;</span><span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span><span style="color: #080;">&#93;</span>
                Marker<span style="color: #F0F;">:</span> <span style="color:#A020F0;">'o'</span>
            MarkerSize<span style="color: #F0F;">:</span> <span style="color: #33f;">5</span>
       MarkerEdgeColor<span style="color: #F0F;">:</span> <span style="color:#A020F0;">'k'</span>
       MarkerFaceColor<span style="color: #F0F;">:</span> <span style="color:#A020F0;">'none'</span>
       MarkerEraseMode<span style="color: #F0F;">:</span> <span style="color:#A020F0;">'normal'</span>
             Draggable<span style="color: #F0F;">:</span> <span style="color:#A020F0;">'on'</span>
                String<span style="color: #F0F;">:</span> <span style="color: #080;">&#123;</span><span style="color:#A020F0;">'Date: 01/09/11'</span>  <span style="color:#A020F0;">'Value: 573.24'</span><span style="color: #080;">&#125;</span>
               Visible<span style="color: #F0F;">:</span> <span style="color:#A020F0;">'on'</span>
             StringFcn<span style="color: #F0F;">:</span> <span style="color: #080;">&#91;</span><span style="color: #080;">&#93;</span>
             UpdateFcn<span style="color: #F0F;">:</span> <span style="color: #080;">&#91;</span><span style="color: #080;">&#93;</span>
         <span style="color: #0000FF;">UIContextMenu</span><span style="color: #F0F;">:</span> <span style="color: #080;">&#91;</span>1x1 <span style="color: #0000FF;">uicontextmenu</span><span style="color: #080;">&#93;</span>
                  Host<span style="color: #F0F;">:</span> <span style="color: #080;">&#91;</span>1x1 graph2d.<span style="">lineseries</span><span style="color: #080;">&#93;</span>
           Interpolate<span style="color: #F0F;">:</span> <span style="color:#A020F0;">'off'</span></pre></div></div><p>We can see that the returned <code>graphics.datatip</code> object includes properties of both the text-box and the marker, making it easy to modify. Moreover, we can use its aforementioned <i>update</i> method to move the datatip to a different plot position (see example in the code above). In addition, we can also use the self-explanatory <i>getCursorInfo(), getaxes(), makeCurrent(), movetofront()</i> methods, and a few others.</p><h3 id="Properties">Cursor mode and data-tip properties</h3><p>The <code>graphics.datacursormanager</code> and the <code>graphics.datatip</code> objects have several public properties that we can use:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">&gt;&gt; cursorMode.<span style="color: #0000FF;">get</span>
              Enable<span style="color: #F0F;">:</span> <span style="color:#A020F0;">'off'</span>
    SnapToDataVertex<span style="color: #F0F;">:</span> <span style="color:#A020F0;">'on'</span>
        DisplayStyle<span style="color: #F0F;">:</span> <span style="color:#A020F0;">'datatip'</span>
           UpdateFcn<span style="color: #F0F;">:</span> @setDataTipTxt
              <span style="color: #0000FF;">Figure</span><span style="color: #F0F;">:</span> <span style="color: #080;">&#91;</span>1x1 <span style="color: #0000FF;">figure</span><span style="color: #080;">&#93;</span>
&nbsp;
&gt;&gt; cursorMode.<span style="">CurrentDataCursor</span>.<span style="color: #0000FF;">get</span>
            Annotation<span style="color: #F0F;">:</span> <span style="color: #080;">&#91;</span>1x1 hg.<span style="">Annotation</span><span style="color: #080;">&#93;</span>
           DisplayName<span style="color: #F0F;">:</span> <span style="color:#A020F0;">''</span>
           HitTestArea<span style="color: #F0F;">:</span> <span style="color:#A020F0;">'off'</span>
      <span style="color: #F0F;">...</span> <span style="color: #228B22;">% See the list above</span></pre></div></div><p>Both these objects have plenty of additional hidden properties. You can inspect them using my <a
target="_blank" rel="nofollow" href="http://www.mathworks.com/matlabcentral/fileexchange/17935-uiinspect-display-methods-properties-callbacks-of-an-object">uiinspect utility</a>. Here is a brief list for reference (R2011b):</p><p><code>graphics.datacursormanager</code>:</p><ul><li>CurrentDataCursor</li><li>DataCursors</li><li>Debug</li><li>DefaultExportVarName</li><li>DefaultPanelPosition</li><li>EnableAxesStacking</li><li>EnableZStacking</li><li>ExternalListeners</li><li>HiddenUpdateFcn</li><li>NewDataCursorOnClick</li><li>OriginalRenderer</li><li>OriginalRendererMode</li><li>PanelDatatipHandle</li><li>PanelHandle</li><li>PanelTextHandle</li><li>UIContextMenu</li><li>UIState</li><li>ZStackMinimum</li></ul><p><code>graphics.datatip</code>:</p><ul><li>ALimInclude</li><li>ApplicationData</li><li>Behavior</li><li>CLimInclude</li><li>DataCursorHandle</li><li>DataManagerHandle</li><li>Debug</li><li>DoThrowStartDragEvent</li><li>EmptyArgUpdateFcn</li><li>EnableAxesStacking</li><li>EnableZStacking</li><li>EraseMode</li><li>EventObject</li><li>ExternalListenerHandles</li><li>HelpTopicKey</li><li>HostAxes</li><li>HostListenerHandles</li><li>IncludeRenderer</li><li>Invalid</li><li>IsDeserializing</li><li>MarkerHandle</li><li>MarkerHandleButtonDownFcn</li><li>Orientation</li><li>OrientationMode</li><li>OrientationPropertyListener</li><li>OriginalDoubleBufferState</li><li>PixelBounds</li><li>PointsOffset</li><li>Position</li><li>SelfListenerHandles</li><li>Serializable</li><li>TextBoxHandle</li><li>TextBoxHandleButtonDownFcn</li><li>Version</li><li>ViewStyle</li><li>XLimInclude</li><li>YLimInclude</li><li>ZLimInclude</li><li>ZStackMinimum</li><li>uistate</li></ul><p>As can be seen, if we really want, we can always use the <b>MarkerHandle</b> or <b>TextBoxHandle</b> directly.</p><h3 id="Deleting">Deleting data tips</h3><p>To delete a specific data-tip, simply call the cursor mode&#8217;s <i>removeDataCursor()</i> method; to delete all data-tips, call its <i>removeAllDataCursors()</i> method:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;"><span style="color: #228B22;">% Delete the current data-tip</span>
cursorMode.<span style="">removeDataCursor</span><span style="color: #080;">&#40;</span>cursorMode.<span style="">CurrentDataCursor</span><span style="color: #080;">&#41;</span>
&nbsp;
<span style="color: #228B22;">% Delete all data-tips</span>
cursorMode.<span style="">removeAllDataCursors</span><span style="color: #080;">&#40;</span><span style="color: #080;">&#41;</span></pre></div></div><p>Have you used plot data-tips in some nifty way? If so, please share your experience in a <a
href="http://undocumentedmatlab.com/blog/controlling-plot-data-tips/#respond">comment</a> below.</p><p>p.s. &#8211; did you notice that Java was not mentioned anywhere above? Mode managers use pure-Matlab functionality.</p><p><pre> </pre>Related posts:<ol><li><a
href='http://undocumentedmatlab.com/blog/accessing-plot-brushed-data/' rel='bookmark' title='Accessing plot brushed data'>Accessing plot brushed data</a> <small>Plot data brushing can be accessed programmatically using very simple pure-Matlab code...</small></li><li><a
href='http://undocumentedmatlab.com/blog/plot-linesmoothing-property/' rel='bookmark' title='Plot LineSmoothing property'>Plot LineSmoothing property</a> <small>LineSmoothing is a hidden and undocumented plot line property that creates anti-aliased (smooth unpixelized) lines in Matlab plots...</small></li><li><a
href='http://undocumentedmatlab.com/blog/plot-liminclude-properties/' rel='bookmark' title='Plot LimInclude properties'>Plot LimInclude properties</a> <small>The plot objects' XLimInclude, YLimInclude, ZLimInclude, ALimInclude and CLimInclude properties are an important feature, that has both functional and performance implications....</small></li><li><a
href='http://undocumentedmatlab.com/blog/com-activex-tips/' rel='bookmark' title='COM/ActiveX tips &amp; tricks'>COM/ActiveX tips &#038; tricks</a> <small>This article describes several little-known tips useful for COM / ActiveX programming in Matlab...</small></li></ol></p><pre> </pre>]]></content:encoded> <wfw:commentRss>http://undocumentedmatlab.com/blog/controlling-plot-data-tips/feed/</wfw:commentRss> <slash:comments>6</slash:comments> </item> <item><title>Uitable sorting</title><link>http://undocumentedmatlab.com/blog/uitable-sorting/</link> <comments>http://undocumentedmatlab.com/blog/uitable-sorting/#comments</comments> <pubDate>Tue, 26 Jul 2011 18:00:01 +0000</pubDate> <dc:creator>Yair Altman</dc:creator> <category><![CDATA[GUI]]></category> <category><![CDATA[Handle graphics]]></category> <category><![CDATA[Hidden property]]></category> <category><![CDATA[High risk of breaking in future versions]]></category> <category><![CDATA[Java]]></category> <category><![CDATA[Semi-documented function]]></category> <category><![CDATA[Stock Matlab function]]></category> <category><![CDATA[Undocumented feature]]></category> <category><![CDATA[HTML]]></category> <category><![CDATA[Internal component]]></category> <category><![CDATA[JIDE]]></category> <category><![CDATA[uitable]]></category> <category><![CDATA[uitools]]></category><guid
isPermaLink="false">http://undocumentedmatlab.com/?p=2391</guid> <description><![CDATA[Matlab's uitables can be sortable using simple undocumented features<pre> </pre>Related posts:<ol><li><a
href='http://undocumentedmatlab.com/blog/uitable-customization-report/' rel='bookmark' title='Uitable customization report'>Uitable customization report</a> <small>In last week&#8217;s report about uitable sorting, I offered a report that I have written which covers uitable customization in detail. Several people have asked for more details about the...</small></li><li><a
href='http://undocumentedmatlab.com/blog/uitable-cell-colors/' rel='bookmark' title='Uitable cell colors'>Uitable cell colors</a> <small>A few Java-based customizations can transform a plain-looking data table into a lively colored one. ...</small></li><li><a
href='http://undocumentedmatlab.com/blog/matlab-and-the-event-dispatch-thread-edt/' rel='bookmark' title='Matlab and the Event Dispatch Thread (EDT)'>Matlab and the Event Dispatch Thread (EDT)</a> <small>The Java Swing Event Dispatch Thread (EDT) is very important for Matlab GUI timings. This article explains the potential pitfalls and their avoidance using undocumented Matlab functionality....</small></li><li><a
href='http://undocumentedmatlab.com/blog/tab-panels-uitab-and-relatives/' rel='bookmark' title='Tab panels &#8211; uitab and relatives'>Tab panels &#8211; uitab and relatives</a> <small>This article describes several undocumented Matlab functions that support tab-panels...</small></li></ol><pre> </pre>]]></description> <content:encoded><![CDATA[<p><a
target="_blank" rel="nofollow" href="http://www.mathworks.com/help/techdoc/ref/uitable.html"><i><b>uitable</b></i></a> is probably the most complex basic GUI controls available in Matlab. It displays data in a table within a figure, with settable properties as with any other Matlab Handle-Graphics (HG) control. After many years in which the <i><b>uitable</b></i> was available but <a
target="_blank" href="http://undocumentedmatlab.com/blog/legend-semi-documented-feature/#Semi-documented">semi-documented</a> and not officially supported in Matlab, it finally became fully documented and supported in R2008a (aka Matlab 7.6). At that time its internal implementation has changed from a MathWorks-developed Java table to a <a
target="_blank" href="http://undocumentedmatlab.com/blog/tag/JIDE/">JIDE</a>-based Java table (another JIDE-derived table was described <a
target="_blank" href="http://undocumentedmatlab.com/blog/jide-property-grids/">here</a> last year). Since R2008a, both versions of <i><b>uitable</b></i> are available &#8211; the old version is available by adding the &#8216;v0&#8242; input arg.</p><p>Matlab&#8217;s <i><b>uitable</b></i> exposes only a very limited subset of functionalities and properties to the user. Numerous other functionalities are available by accessing the underlying Java table and hidden Matlab properties. Today I will describe a very <a
target="_blank" rel="nofollow" href="http://www.mathworks.com/matlabcentral/answers/1880-uitable-can-the-headers-be-made-clickable">common need</a> in GUI tables, that for some unknown reason is missing in Matlab&#8217;s <i><b>uitable</b></i>: Sorting table data columns.</p><p>Last week I <a
target="_blank" href="http://undocumentedmatlab.com/blog/running-vb-code-in-matlab/">explained</a> how we can modify table headers of an ActiveX table control to display sorting icons. In that case, sorting was built-in the control, and the question was just how to display the sorting arrow icon. Unfortunately, Matlab&#8217;s <i><b>uitable</b></i> does not have sorting built-in, although it&#8217;s quite easy to add it, as I shall now show.</p><h3 id="Old">Old uitable sorting</h3><p>The old <i><b>uitable</b></i> is the default control used until R2007b, or that can be selected with the &#8216;v0&#8242; input arg since R2008a. It was based on an internal MathWorks extension of the standard Java Swing <a
target="_blank" rel="nofollow" href="http://download.oracle.com/javase/tutorial/uiswing/components/table.html">JTable</a> &#8211; a class called <code>com.mathworks.widgets.spreadsheet.SpreadsheetTable</code>.</p><p>Users will normally try to sort columns by clicking the header. This has been a deficiency of JTable for ages. To solve this for the old (pre-R2008a) <i><b>uitable</b></i>, download one of several available JTable sorter classes, or my TableSorter class (available <a
target="_blank" rel="nofollow" href="http://www.mathworks.com/matlabcentral/fileexchange/14225-java-based-data-table">here</a>).  Add the TableSorter.jar file to your static java classpath (via <code>edit('classpath.txt')</code>) or your dynamic classpath (<code>javaaddpath('TableSorter.jar')</code>).</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;"><span style="color: #228B22;">% Display the uitable and get its underlying Java object handle</span>
<span style="color: #080;">&#91;</span>mtable,hcontainer<span style="color: #080;">&#93;</span> = uitable<span style="color: #080;">&#40;</span><span style="color:#A020F0;">'v0'</span>, <span style="color: #0000FF;">gcf</span>, <span style="color: #0000FF;">magic</span><span style="color: #080;">&#40;</span><span style="color: #33f;">3</span><span style="color: #080;">&#41;</span>, <span style="color: #080;">&#123;</span><span style="color:#A020F0;">'A'</span>, <span style="color:#A020F0;">'B'</span>, <span style="color:#A020F0;">'C'</span><span style="color: #080;">&#125;</span><span style="color: #080;">&#41;</span>;   <span style="color: #228B22;">% discard the 'v0' in R2007b and earlier</span>
jtable = mtable.<span style="">getTable</span>;   <span style="color: #228B22;">% or: get(mtable,'table');</span>
&nbsp;
<span style="color: #228B22;">% We want to use sorter, not data model...</span>
<span style="color: #228B22;">% Unfortunately, UitablePeer expects DefaultTableModel not TableSorter so we need a modified UitablePeer class</span>
<span style="color: #228B22;">% But UitablePeer is a Matlab class, so use a modified TableSorter &amp; attach it to the Model</span>
<span style="color: #0000FF;">if</span> ~<span style="color: #0000FF;">isempty</span><span style="color: #080;">&#40;</span><span style="color: #0000FF;">which</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'TableSorter'</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>
   <span style="color: #228B22;">% Add TableSorter as TableModel listener</span>
   sorter = TableSorter<span style="color: #080;">&#40;</span>jtable.<span style="">getModel</span><span style="color: #080;">&#40;</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>;
   jtable.<span style="">setModel</span><span style="color: #080;">&#40;</span>sorter<span style="color: #080;">&#41;</span>;
   sorter.<span style="">setTableHeader</span><span style="color: #080;">&#40;</span>jtable.<span style="">getTableHeader</span><span style="color: #080;">&#40;</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>;
&nbsp;
   <span style="color: #228B22;">% Set the header tooltip (with sorting instructions)</span>
   jtable.<span style="">getTableHeader</span>.<span style="">setToolTipText</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'&lt;html&gt;&amp;nbsp;&lt;b&gt;Click&lt;/b&gt; to sort up; &lt;b&gt;Shift-click&lt;/b&gt; to sort down&lt;br /&gt;&amp;nbsp;...&lt;/html&gt;'</span><span style="color: #080;">&#41;</span>;
&nbsp;
<span style="color: #0000FF;">else</span>
   <span style="color: #228B22;">% Set the header tooltip (no sorting instructions...)</span>
   jtable.<span style="">getTableHeader</span>.<span style="">setToolTipText</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'&lt;html&gt;&amp;nbsp;&lt;b&gt;Click&lt;/b&gt; to select entire column&lt;br /&gt;&amp;nbsp;&lt;b&gt;Ctrl-click&lt;/b&gt; (or &lt;b&gt;Shift-click&lt;/b&gt;) to select multiple columns&amp;nbsp;&lt;/html&gt;'</span><span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">end</span></pre></div></div><p><center><div
class="wp-caption aligncenter" style="width: 607px"><img
alt="Sorted uitable - old version" src="http://www.mathworks.com/matlabcentral/fx_files/14225/1/table.png" title="Sorted uitable - old version" width="597" /><p
class="wp-caption-text">Sorted <i><b>uitable</b></i> - old version</p></div></center></p><h3 id="New">New uitable sorting</h3><p>The new <i><b>uitable</b></i> is based on JIDE&#8217;s <code>com.jidesoft.grid.SortableTable</code> and so has built-in sorting support – all you need to do is to turn it on. First get the underlying Java object using my <a
target="_blank" href="http://undocumentedmatlab.com/blog/findjobj-find-underlying-java-object/">FindJObj utility</a>:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;"><span style="color: #228B22;">% Display the uitable and get its underlying Java object handle</span>
mtable = uitable<span style="color: #080;">&#40;</span><span style="color: #0000FF;">gcf</span>, <span style="color:#A020F0;">'Data'</span>,<span style="color: #0000FF;">magic</span><span style="color: #080;">&#40;</span><span style="color: #33f;">3</span><span style="color: #080;">&#41;</span>, <span style="color:#A020F0;">'ColumnName'</span>,<span style="color: #080;">&#123;</span><span style="color:#A020F0;">'A'</span>, <span style="color:#A020F0;">'B'</span>, <span style="color:#A020F0;">'C'</span><span style="color: #080;">&#125;</span><span style="color: #080;">&#41;</span>;
jscrollpane = findjobj<span style="color: #080;">&#40;</span>mtable<span style="color: #080;">&#41;</span>;
jtable = jscrollpane.<span style="">getViewport</span>.<span style="">getView</span>;
&nbsp;
<span style="color: #228B22;">% Now turn the JIDE sorting on</span>
jtable.<span style="">setSortable</span><span style="color: #080;">&#40;</span><span style="color: #0000FF;">true</span><span style="color: #080;">&#41;</span>;		<span style="color: #228B22;">% or: set(jtable,'Sortable','on');</span>
jtable.<span style="">setAutoResort</span><span style="color: #080;">&#40;</span><span style="color: #0000FF;">true</span><span style="color: #080;">&#41;</span>;
jtable.<span style="">setMultiColumnSortable</span><span style="color: #080;">&#40;</span><span style="color: #0000FF;">true</span><span style="color: #080;">&#41;</span>;
jtable.<span style="">setPreserveSelectionsAfterSorting</span><span style="color: #080;">&#40;</span><span style="color: #0000FF;">true</span><span style="color: #080;">&#41;</span>;</pre></div></div><p>Note: the Matlab <code>mtable</code> handle has a hidden <b>Sortable</b> property, but it has no effect – use the Java property mentioned above instead. I assume that the hidden <b>Sortable</b> property was meant to implement the sorting behavior in R2008a, but MathWorks never got around to actually implement it, and so it remains this way to this day.</p><h3 id="Report">A more detailed report</h3><p>I have prepared a 30-page report about using and customizing Matlab&#8217;s <i><b>uitable</b></i>, which greatly expands on the above. This report is available for a small fee <a
target="_blank" rel="nofollow" href="https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&#038;business=ymasoftware@gmail.com&#038;currency_code=USD&#038;amount=35&#038;return=&#038;item_name=Matlab-uitable-report">here</a> (please allow up to 48 hours for email delivery). The report includes the following:</p><ul><li>comparison of the old vs. the new <i><b>uitable</b></i> implementations</li><li>description of the <i><b>uitable</b></i> properties and callbacks</li><li>alternatives to <i><b>uitable</b></i> using a variety of technologies</li><li>updating a specific cell&#8217;s value</li><li>setting background and foreground colors for a cell or column</li><li>using dedicated cell renderer and editor components</li><li>HTML processing</li><li>setting dynamic cell-specific tooltip</li><li>setting dynamic cell-specific drop-down selection options</li><li>using a color-selection drop-down for cells</li><li>customizing scrollbars</li><li>customizing column widths and resizing</li><li>customizing selection behavior</li><li>data sorting (expansion of today&#8217;s article)</li><li>data filtering (similar to Excel&#8217;s data filtering control)</li><li>merging table cells</li><li>programmatically adding/removing rows</li><li>numerous links to online resources</li><li>overview of the JIDE grids package, which contains numerous extremely useful GUI controls and components</li></ul><p><pre> </pre>Related posts:<ol><li><a
href='http://undocumentedmatlab.com/blog/uitable-customization-report/' rel='bookmark' title='Uitable customization report'>Uitable customization report</a> <small>In last week&#8217;s report about uitable sorting, I offered a report that I have written which covers uitable customization in detail. Several people have asked for more details about the...</small></li><li><a
href='http://undocumentedmatlab.com/blog/uitable-cell-colors/' rel='bookmark' title='Uitable cell colors'>Uitable cell colors</a> <small>A few Java-based customizations can transform a plain-looking data table into a lively colored one. ...</small></li><li><a
href='http://undocumentedmatlab.com/blog/matlab-and-the-event-dispatch-thread-edt/' rel='bookmark' title='Matlab and the Event Dispatch Thread (EDT)'>Matlab and the Event Dispatch Thread (EDT)</a> <small>The Java Swing Event Dispatch Thread (EDT) is very important for Matlab GUI timings. This article explains the potential pitfalls and their avoidance using undocumented Matlab functionality....</small></li><li><a
href='http://undocumentedmatlab.com/blog/tab-panels-uitab-and-relatives/' rel='bookmark' title='Tab panels &#8211; uitab and relatives'>Tab panels &#8211; uitab and relatives</a> <small>This article describes several undocumented Matlab functions that support tab-panels...</small></li></ol></p><pre> </pre>]]></content:encoded> <wfw:commentRss>http://undocumentedmatlab.com/blog/uitable-sorting/feed/</wfw:commentRss> <slash:comments>16</slash:comments> </item> <item><title>Minimize/maximize figure window</title><link>http://undocumentedmatlab.com/blog/minimize-maximize-figure-window/</link> <comments>http://undocumentedmatlab.com/blog/minimize-maximize-figure-window/#comments</comments> <pubDate>Wed, 18 May 2011 23:08:07 +0000</pubDate> <dc:creator>Yair Altman</dc:creator> <category><![CDATA[Figure window]]></category> <category><![CDATA[GUI]]></category> <category><![CDATA[Hidden property]]></category> <category><![CDATA[Java]]></category> <category><![CDATA[Medium risk of breaking in future versions]]></category> <category><![CDATA[Undocumented feature]]></category> <category><![CDATA[Undocumented function]]></category> <category><![CDATA[Donn Shull]]></category> <category><![CDATA[JavaFrame]]></category> <category><![CDATA[Undocumented property]]></category><guid
isPermaLink="false">http://undocumentedmatlab.com/?p=2310</guid> <description><![CDATA[Matlab figure windows can easily be maximized, minimized and restored using a bit of undocumented magic powder<pre> </pre>Related posts:<ol><li><a
href='http://undocumentedmatlab.com/blog/disable-entire-figure-window/' rel='bookmark' title='Enable/disable entire figure window'>Enable/disable entire figure window</a> <small>Disabling/enabling an entire figure window is impossible with pure Matlab, but is very simple using the underlying Java. This article explains how....</small></li><li><a
href='http://undocumentedmatlab.com/blog/transparent-matlab-figure-window/' rel='bookmark' title='Transparent Matlab figure window'>Transparent Matlab figure window</a> <small>Matlab figure windows can be made fully or partially transparent/translucent or blurred - this article explains how...</small></li><li><a
href='http://undocumentedmatlab.com/blog/blurred-matlab-figure-window/' rel='bookmark' title='Blurred Matlab figure window'>Blurred Matlab figure window</a> <small>Matlab figure windows can be blurred using a semi-transparent overlaid window - this article explains how...</small></li><li><a
href='http://undocumentedmatlab.com/blog/detecting-window-focus-events/' rel='bookmark' title='Detecting window focus events'>Detecting window focus events</a> <small>Matlab does not have any documented method to detect window focus events (gain/loss). This article describes an undocumented way to detect such events....</small></li></ol><pre> </pre>]]></description> <content:encoded><![CDATA[<p>Over the past couple of years, I posted <a
target="_blank" href="http://undocumentedmatlab.com/blog/tag/javaframe/">several articles</a> using the <b>JavaFrame</b> property of the figure handle, which enables access to the GUI&#8217;s underlying Java peer object. Today, I show how using <b>JavaFrame</b> we can solve a very frequent user request on the Matlab CSSM forum.</p><h3 id="Problem">The problem</h3><p>Matlab figures can be maximized, minimized and restored by <em>interactively</em> clicking the corresponding icon (or menu item) on the figure window&#8217;s frame (the title bar). However, we often need to create maximized main-application windows, and wish to save the users the need to manually maximize the window. Moreover, we may sometimes even wish to prevent users from resizing a maximized main window.</p><p>Unfortunately, Matlab does not contain any documented or supported way to <em>programmatically</em> maximize, minimize or restore a figure window.</p><p>This is very strange considering the fact that these are such elementary figure operations. Moreover, these operations are supported internally (and have been for many releases already), as shown below. It is therefore difficult for me to understand why they were not added to the documented Matlab HG wrapper functionality a long time ago. I fail to understand why obscure features such as docking were added to the wrapper, but standard minimization and maximization were not.</p><h3 id="Maximization">Maximization</h3><p><a
target="_blank" rel="nofollow" href="http://www.mathworks.com/matlabcentral/fileexchange/?term=maximize+window">Several solutions</a> have been presented to this problem over the years. Let us start with the pressing question of figure maximization:</p><p>Solutions that rely on documented Matlab features tend to compute the available screen size and resize the figure accordingly. The result is lacking in many respects: it does not account for the taskbar (neither in size nor in location, which is not necessarily at the bottom of the screen); it does not remove the window border as in regular maximized figures; and it often ignores extended desktops (i.e. an attached additional monitor).</p><p>The solutions that do work properly all rely on undocumented features: Some use platform-specific native Windows API in a mex-file (Jan Simon&#8217;s recent <a
target="_blank" rel="nofollow" href="http://www.mathworks.com/matlabcentral/fileexchange/31437-windowapi">WindowAPI</a> submission really pushes the limit in this and other regards). Alternately, we can easily use the platform-independent <b>JavaFrame</b>:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">&gt;&gt; jFrame = <span style="color: #0000FF;">get</span><span style="color: #080;">&#40;</span>handle<span style="color: #080;">&#40;</span><span style="color: #0000FF;">gcf</span><span style="color: #080;">&#41;</span>,<span style="color:#A020F0;">'JavaFrame'</span><span style="color: #080;">&#41;</span>
jFrame =
com.<span style="">mathworks</span>.<span style="">hg</span>.<span style="">peer</span>.<span style="">FigurePeer</span>@cdbd96
&nbsp;
&gt;&gt; jFrame.<span style="">setMaximized</span><span style="color: #080;">&#40;</span><span style="color: #0000FF;">true</span><span style="color: #080;">&#41;</span>;   <span style="color: #228B22;">% to maximize the figure</span>
&gt;&gt; jFrame.<span style="">setMaximized</span><span style="color: #080;">&#40;</span><span style="color: #0000FF;">false</span><span style="color: #080;">&#41;</span>;  <span style="color: #228B22;">% to un-maximize the figure</span></pre></div></div><h3 id="Minimization">Minimization</h3><p>To the best of my knowledge, there are no solutions for minimizing figure windows that use documented Matlab features. Again, this can be done using either native Windows API, or the platform-independent <b>JavaFrame</b>:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">&gt;&gt; jFrame.<span style="">setMinimized</span><span style="color: #080;">&#40;</span><span style="color: #0000FF;">true</span><span style="color: #080;">&#41;</span>;   <span style="color: #228B22;">% to minimize the figure</span>
&gt;&gt; jFrame.<span style="">setMinimized</span><span style="color: #080;">&#40;</span><span style="color: #0000FF;">false</span><span style="color: #080;">&#41;</span>;  <span style="color: #228B22;">% to un-minimize the figure</span></pre></div></div><h3 id="Notes">Usage notes</h3><p><b>Maximized</b> and <b>Minimized</b> are mutually-exclusive, meaning that no more than one of them can be 1 (or true) at any time. This is automatically handled – users only need to be aware that a situation in which a window is both maximized and minimized at the same time is impossible (duh!).</p><p>There are several equivalent manners of setting <code>jFrame</code>&#8216;s <b>Maximized</b> and <b>Minimized</b> property values, and your choice may simply be a matter of aesthetics and personal taste:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;"><span style="color: #228B22;">% Three alternative possibilities of setting Maximized:</span>
jFrame.<span style="">setMaximized</span><span style="color: #080;">&#40;</span><span style="color: #0000FF;">true</span><span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">set</span><span style="color: #080;">&#40;</span>jFrame,<span style="color:#A020F0;">'Maximized'</span>,<span style="color: #0000FF;">true</span><span style="color: #080;">&#41;</span>;   <span style="color: #228B22;">% note interchangeable 1&lt; =&gt;true, 0&lt; =&gt;false</span>
jFrame.<span style="">handle</span>.<span style="">Maximized</span> = <span style="color: #33f;">1</span>;</pre></div></div><p><code>jFrame</code> follows Java convention: the accessor method that retrieves boolean values is called <i>is&lt;Propname&gt;()</i> instead of <i>get&lt;Propname&gt;</i>. In our case: <i>isMaximized()</i> and <i>isMinimized()</i>:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;"><span style="color: #0000FF;">flag</span> = jFrame.<span style="">isMinimized</span>;        <span style="color: #228B22;">% Note: isMinimized, not getMinimized</span>
<span style="color: #0000FF;">flag</span> = <span style="color: #0000FF;">get</span><span style="color: #080;">&#40;</span>jFrame,<span style="color:#A020F0;">'Minimized'</span><span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">flag</span> = jFrame.<span style="">handle</span>.<span style="">Minimized</span>;</pre></div></div><p>In some old Matlab releases, <code>jFrame</code> did not possess the <b>Maximized</b> and <b>Minimized</b> properties, and their associated accessor methods. In this case, use the internal <code>FrameProxy</code> which has always contained them:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">&gt;&gt; jFrameProxy = jFrame.<span style="">fFigureClient</span>.<span style="">getWindow</span><span style="color: #080;">&#40;</span><span style="color: #080;">&#41;</span> 
jFrameProxy =
com.<span style="">mathworks</span>.<span style="">hg</span>.<span style="">peer</span>.<span style="">FigureFrameProxy</span>$FigureFrame<span style="color: #080;">&#91;</span>fClientProxyFrame,<span style="color: #33f;">227</span>,<span style="color: #33f;">25</span>,568x502,invalid,layout=java.<span style="">awt</span>.<span style="">BorderLayout</span>,<span style="color: #0000FF;">title</span>=<span style="color: #0000FF;">Figure</span> <span style="color: #33f;">1</span>,resizable,normal,defaultCloseOperation=DO_NOTHING_ON_CLOSE,<span style="color: #F0F;">...</span><span style="color: #080;">&#93;</span>
&nbsp;
&gt;&gt; <span style="color: #228B22;">% Three alternative possibilities of setting Minimized:</span>
&gt;&gt; jFrameProxy.<span style="">setMinimized</span><span style="color: #080;">&#40;</span><span style="color: #0000FF;">true</span><span style="color: #080;">&#41;</span>;
&gt;&gt; <span style="color: #0000FF;">set</span><span style="color: #080;">&#40;</span>jFrameProxy,<span style="color:#A020F0;">'Minimized'</span>,<span style="color: #0000FF;">true</span><span style="color: #080;">&#41;</span>;
&gt;&gt; jFrameProxy.<span style="">handle</span>.<span style="">Minimized</span> = <span style="color: #0000FF;">true</span>;</pre></div></div><p>Using <code>FrameProxy</code> for figure minimization and maximization works correctly on both old and new Matlab releases; using <code>jFrame</code> is slightly simpler but only works on recent Matlab releases. Depending on your needs you may choose to use either of these. They are entirely equivalent.</p><p>When either the <b>Maximized</b> or <b>Minimized</b> properties are changed back to false, the window is restored to regular mode, which is the <code>FrameProxy</code>&#8216;s <b>RestoredLocation</b> and <b>RestoredSize</b>.</p><h3 id="JavaFrame">Use of the JavaFrame property</h3><p>Note that all this relies on the undocumented hidden figure property <b>JavaFrame</b>, which issues a standing warning (since Matlab release R2008a) of becoming obsolete in some future Matlab release (HG2?):</p><div
class="wp_syntax"><div
class="code"><pre style="font-family: monospace;"><span style="color: #000000;">>> jFrame = </span><span style="color: #0000ff;">get</span>(<span style="color: #0000ff;">gcf</span>,<span style="color: #800080;">'JavaFrame'</span>)
<span style="color: #ff0000;">Warning: figure JavaFrame property will be obsoleted in a future release.</span>
<span style="color: #000000;">For more information see the JavaFrame resource on the MathWorks web site.
(Type "warning off MATLAB:HandleGraphics:ObsoletedProperty:JavaFrame" to suppress this warning.) 

jFrame =
com.mathworks.hg.peer.FigurePeer@1ffbad6</span>
</pre></div></div><p>To remove the above warning I have used (note the <i><b>handle</b></i> wrapper, as <a
target="_blank" href="http://undocumentedmatlab.com/blog/detecting-window-focus-events/#comment-2756">suggested</a> by Donn Shull):</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">jFrame = <span style="color: #0000FF;">get</span><span style="color: #080;">&#40;</span>handle<span style="color: #080;">&#40;</span><span style="color: #0000FF;">gcf</span><span style="color: #080;">&#41;</span>,<span style="color:#A020F0;">'JavaFrame'</span><span style="color: #080;">&#41;</span></pre></div></div><p>If and when <b>JavaFrame</b> does become obsolete in some future Matlab version, be sure to look in this blog for workarounds.</p><p>You may also wish to inform MathWorks on the dedicated webpage that they have set up for specifically this reason (<a
target="_blank" rel="nofollow" href="http://www.mathworks.com/javaframe">http://www.mathworks.com/javaframe</a>), how you are using <b>JavaFrame</b> and why it is important for you. This may help them to decide whether to keep <b>JavaFrame</b> or possibly add the functionality using other means.</p><p>Do you have a smart use for the figure&#8217;s minimization or maximization feature? or another use for <b>JavaFrame</b>? If so, please share your ideas in a <a
target="_blank" href="http://UndocumentedMatlab.com/blog/minimize-maximize-figure-window#respond">comment</a> below.</p><p><pre> </pre>Related posts:<ol><li><a
href='http://undocumentedmatlab.com/blog/disable-entire-figure-window/' rel='bookmark' title='Enable/disable entire figure window'>Enable/disable entire figure window</a> <small>Disabling/enabling an entire figure window is impossible with pure Matlab, but is very simple using the underlying Java. This article explains how....</small></li><li><a
href='http://undocumentedmatlab.com/blog/transparent-matlab-figure-window/' rel='bookmark' title='Transparent Matlab figure window'>Transparent Matlab figure window</a> <small>Matlab figure windows can be made fully or partially transparent/translucent or blurred - this article explains how...</small></li><li><a
href='http://undocumentedmatlab.com/blog/blurred-matlab-figure-window/' rel='bookmark' title='Blurred Matlab figure window'>Blurred Matlab figure window</a> <small>Matlab figure windows can be blurred using a semi-transparent overlaid window - this article explains how...</small></li><li><a
href='http://undocumentedmatlab.com/blog/detecting-window-focus-events/' rel='bookmark' title='Detecting window focus events'>Detecting window focus events</a> <small>Matlab does not have any documented method to detect window focus events (gain/loss). This article describes an undocumented way to detect such events....</small></li></ol></p><pre> </pre>]]></content:encoded> <wfw:commentRss>http://undocumentedmatlab.com/blog/minimize-maximize-figure-window/feed/</wfw:commentRss> <slash:comments>9</slash:comments> </item> <item><title>Transparent Matlab figure window</title><link>http://undocumentedmatlab.com/blog/transparent-matlab-figure-window/</link> <comments>http://undocumentedmatlab.com/blog/transparent-matlab-figure-window/#comments</comments> <pubDate>Wed, 13 Apr 2011 23:22:38 +0000</pubDate> <dc:creator>Yair Altman</dc:creator> <category><![CDATA[Figure window]]></category> <category><![CDATA[GUI]]></category> <category><![CDATA[Hidden property]]></category> <category><![CDATA[Java]]></category> <category><![CDATA[Medium risk of breaking in future versions]]></category> <category><![CDATA[Desktop]]></category> <category><![CDATA[JavaFrame]]></category><guid
isPermaLink="false">http://undocumentedmatlab.com/?p=2246</guid> <description><![CDATA[Matlab figure windows can be made fully or partially transparent/translucent or blurred - this article explains how<pre> </pre>Related posts:<ol><li><a
href='http://undocumentedmatlab.com/blog/blurred-matlab-figure-window/' rel='bookmark' title='Blurred Matlab figure window'>Blurred Matlab figure window</a> <small>Matlab figure windows can be blurred using a semi-transparent overlaid window - this article explains how...</small></li><li><a
href='http://undocumentedmatlab.com/blog/minimize-maximize-figure-window/' rel='bookmark' title='Minimize/maximize figure window'>Minimize/maximize figure window</a> <small>Matlab figure windows can easily be maximized, minimized and restored using a bit of undocumented magic powder...</small></li><li><a
href='http://undocumentedmatlab.com/blog/disable-entire-figure-window/' rel='bookmark' title='Enable/disable entire figure window'>Enable/disable entire figure window</a> <small>Disabling/enabling an entire figure window is impossible with pure Matlab, but is very simple using the underlying Java. This article explains how....</small></li><li><a
href='http://undocumentedmatlab.com/blog/detecting-window-focus-events/' rel='bookmark' title='Detecting window focus events'>Detecting window focus events</a> <small>Matlab does not have any documented method to detect window focus events (gain/loss). This article describes an undocumented way to detect such events....</small></li></ol><pre> </pre>]]></description> <content:encoded><![CDATA[<p>Every now and then, a user asks whether it is possible to make an entire Matlab window transparent (<a
target="_blank" rel="nofollow" href="http://www.mathworks.com/matlabcentral/newsreader/view_thread/280394">example</a>). This could be used, for example, for window fade-in/fade-out effects. The short answer is that there is no supported way of doing this with pure documented Matlab, but it is trivially easy to achieve using just a bit of Java magic powder (surprise, surprise).</p><h3 id="transparency">Matlab figure window transparency</h3><p>Following an idea I got from Malcolm Lidierth&#8217;s <a
target="_blank" rel="nofollow" href="http://www.mathworks.com/matlabcentral/fileexchange/28326-mutilities">MUtilities</a> submission on the Matlab File Exchange, the solution for setting Matlab figure window transparency is quite simple: Get the figure&#8217;s underlying Java window reference handle, as in <a
target="_blank" href="http://undocumentedmatlab.com/blog/disable-entire-figure-window/">last week&#8217;s</a> article. Then use Java&#8217;s <a
target="_blank" rel="nofollow" href="http://www.pushing-pixels.org/2008/02/27/translucent-and-shaped-windows-in-core-java.html"><i>setWindowOpacity</i> method</a> to set the window&#8217;s transparency value. Actually, <i>setWindowOpacity</i> sets the opacity level, rather than transparency, but they are obviously complementary and I personally find &#8220;transparency&#8221; to be more easily understandable.</p><p>By default, windows are created with an opacity of 1.0 (= not transparent). They can be set to any floating-point value between 0.0-1.0, where an opacity of 0.0 means full transparency, and any value in between means partial transparency (i.e., translucency):</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">jFigPeer = <span style="color: #0000FF;">get</span><span style="color: #080;">&#40;</span>handle<span style="color: #080;">&#40;</span><span style="color: #0000FF;">gcf</span><span style="color: #080;">&#41;</span>,<span style="color:#A020F0;">'JavaFrame'</span><span style="color: #080;">&#41;</span>;
jWindow = jFigPeer.<span style="">fFigureClient</span>.<span style="">getWindow</span>;
com.<span style="">sun</span>.<span style="">awt</span>.<span style="">AWTUtilities</span>.<span style="">setWindowOpacity</span><span style="color: #080;">&#40;</span>jWindow,<span style="color: #33f;">0.7</span><span style="color: #080;">&#41;</span></pre></div></div><p><center><div
class="wp-caption aligncenter" style="width: 510px"><a
target="_blank" rel="nofollow" href="http://www.mathworks.com/matlabcentral/fx_files/30583/1/setFigTransparency.png"><img
alt="Semi-transparent (translucent) Matlab figure (click to enlarge)" src="http://www.mathworks.com/matlabcentral/fx_files/30583/1/setFigTransparency.png" title="Semi-transparent (translucent) Matlab figure (click to enlarge)" width="500" /></a><p
class="wp-caption-text">Semi-transparent (translucent) Matlab figure (click to enlarge)</p></div></center></p><p>Similarly, you can set the entire Matlab Desktop&#8217;s transparency/opacity value:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">jDesktop = com.<span style="">mathworks</span>.<span style="">mde</span>.<span style="">desk</span>.<span style="">MLDesktop</span>.<span style="">getInstance</span>.<span style="">getMainFrame</span>;
com.<span style="">sun</span>.<span style="">awt</span>.<span style="">AWTUtilities</span>.<span style="">setWindowOpacity</span><span style="color: #080;">&#40;</span>jDesktop, <span style="color: #33f;">0.8</span><span style="color: #080;">&#41;</span>;</pre></div></div><p>Note that the <code>com.sun.awt.AWTUtilities</code> class also enables <a
target="_blank" rel="nofollow" href="http://today.java.net/pub/a/today/2008/03/18/translucent-and-shaped-swing-windows.html">other GUI effects</a> that would make a Matlab GUI developer&#8217;s mouth to start drooling: shaped windows, per-pixel transparency values, mirroring/reflection, window shadows, <a
target="_blank" rel="nofollow" href="http://java.sun.com/developer/technicalArticles/GUI/translucent_shaped_windows/">gradients</a> etc. Perhaps I&#8217;ll explore their adaptation for Matlab figures someday.</p><h3 id="Fade">Fade-in / fade-out</h3><p>Window fade-in/fade-out effects can easily be achieved using transparency: Simply invoke the <i>setWindowOpacity</i> method several times, with progressively higher or lower values. This is easily done in a simple blocking loop. For example, to fade-out a window:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;"><span style="color: #0000FF;">for</span> stepIdx = <span style="color: #33f;">1</span> <span style="color: #F0F;">:</span> <span style="color: #33f;">5</span>
   newAlpha = <span style="color: #33f;">1.0</span> - <span style="color: #33f;">0.2</span>*stepIdx;
   com.<span style="">sun</span>.<span style="">awt</span>.<span style="">AWTUtilities</span>.<span style="">setWindowOpacity</span><span style="color: #080;">&#40;</span>jWindow,newAlpha<span style="color: #080;">&#41;</span>;
   jWindow.<span style="">repaint</span>;
   <span style="color: #0000FF;">pause</span><span style="color: #080;">&#40;</span><span style="color: #33f;">0.2</span><span style="color: #080;">&#41;</span>;  <span style="color: #228B22;">% seconds</span>
<span style="color: #0000FF;">end</span></pre></div></div><p><center><div
class="wp-caption aligncenter" style="width: 310px"><img
alt="Gradual window fade-out" src="http://UndocumentedMatlab.com/images/transparent_figure_animated.gif" title="Gradual window fade-out" width="300" /><p
class="wp-caption-text">Gradual window fade-out</p></div></center></p><p>A more general example dynamically computes the opacity step size/duration and also enables non-blocking fade effects using an asynchronous timer:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;"><span style="color: #228B22;">% Compute the required opacity-setting steps</span>
fadeDuration = <span style="color: #33f;">1.5</span>;  <span style="color: #228B22;">% seconds</span>
oldAlpha = com.<span style="">sun</span>.<span style="">awt</span>.<span style="">AWTUtilities</span>.<span style="">getWindowOpacity</span><span style="color: #080;">&#40;</span>jWindow<span style="color: #080;">&#41;</span>;
newAlpha = <span style="color: #33f;">0.0</span>;
deltaAlpha = newAlpha - oldAlpha;
maxStepAlpha = <span style="color: #33f;">0.03</span>;
steps = <span style="color: #0000FF;">fix</span><span style="color: #080;">&#40;</span><span style="color: #0000FF;">abs</span><span style="color: #080;">&#40;</span>deltaAlpha<span style="color: #080;">&#41;</span> / maxStepAlpha<span style="color: #080;">&#41;</span> + <span style="color: #33f;">1</span>;
stepAlpha = deltaAlpha / steps;
stepDuration = fadeDuration / <span style="color: #080;">&#40;</span>steps-<span style="color: #33f;">1</span><span style="color: #080;">&#41;</span>;
&nbsp;
<span style="color: #228B22;">% If blocking, do the fade effect immediately</span>
<span style="color: #0000FF;">if</span> blockingFlag <span style="color: #F0F;">||</span> steps==<span style="color: #33f;">1</span>
   <span style="color: #0000FF;">for</span> stepIdx = <span style="color: #33f;">1</span> <span style="color: #F0F;">:</span> steps
      newAlpha = oldAlpha + stepAlpha*stepIdx;
      com.<span style="">sun</span>.<span style="">awt</span>.<span style="">AWTUtilities</span>.<span style="">setWindowOpacity</span><span style="color: #080;">&#40;</span>jWindow,newAlpha<span style="color: #080;">&#41;</span>;
      jWindow.<span style="">repaint</span>;
      <span style="color: #0000FF;">if</span> stepIdx &lt; steps,  <span style="color: #0000FF;">pause</span><span style="color: #080;">&#40;</span>stepDuration<span style="color: #080;">&#41;</span>;  <span style="color: #0000FF;">end</span>
   <span style="color: #0000FF;">end</span>
<span style="color: #0000FF;">else</span>
   <span style="color: #228B22;">% non-blocking: fade in/out asynchronously using a dedicated timer</span>
   start<span style="color: #080;">&#40;</span>timer<span style="color: #080;">&#40;</span><span style="color:#A020F0;">'ExecutionMode'</span>,<span style="color:#A020F0;">'fixedRate'</span>, <span style="color:#A020F0;">'Period'</span>,<span style="color: #33f;">0.1</span>, <span style="color:#A020F0;">'TasksToExecute'</span>,steps, <span style="color: #F0F;">...</span>
               <span style="color:#A020F0;">'TimerFcn'</span>, <span style="color: #080;">&#123;</span>@timerFcn,jWindow,oldAlpha,stepAlpha<span style="color: #080;">&#125;</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">end</span>
&nbsp;
<span style="color: #228B22;">% Timer function for non-blocking fade-in/fade-out effect</span>
<span style="color: #0000FF;">function</span> timerFcn<span style="color: #080;">&#40;</span>hTimer,eventData,jFrame,currentAlpha,stepAlpha<span style="color: #080;">&#41;</span>  <span style="color: #228B22;">%#ok&lt;INUSL&gt; eventData</span>
  stepIdx = hTimer.<span style="">TasksExecuted</span>;
  newAlpha = currentAlpha + stepAlpha*stepIdx;
  com.<span style="">sun</span>.<span style="">awt</span>.<span style="">AWTUtilities</span>.<span style="">setWindowOpacity</span><span style="color: #080;">&#40;</span>jFrame,newAlpha<span style="color: #080;">&#41;</span>;
  jFrame.<span style="">repaint</span>;
  <span style="color: #0000FF;">if</span> stepIdx == hTimer.<span style="">TasksToExecute</span>
      stop<span style="color: #080;">&#40;</span>hTimer<span style="color: #080;">&#41;</span>;
      <span style="color: #0000FF;">delete</span><span style="color: #080;">&#40;</span>hTimer<span style="color: #080;">&#41;</span>;
  <span style="color: #0000FF;">end</span>
<span style="color: #0000FF;">end</span>  <span style="color: #228B22;">% timerFcn</span></pre></div></div><p>Of course, you can also fade-in/out to intermediate values such as 0.3 or 0.8. If you fade-out completely (i.e., to a value of 0.0), it might be a good idea to actually <i><b>close</b></i> the figure window once it gets the totally-transparent value of 0.0.</p><p>I&#8217;ve prepared a Matlab utility that contains all these options, including optional blocking/non-blocking fade effects, in my <a
target="_blank" rel="nofollow" href="http://www.mathworks.com/matlabcentral/fileexchange/30583-setfigtransparency-set-figure-transparency-fading"><i><b>setFigTransparency</b></i> utility</a>, which is available for download on the Matlab File Exchange. You may also wish to use Malcolm Lidierth&#8217;s <a
target="_blank" rel="nofollow" href="http://www.mathworks.com/matlabcentral/fileexchange/28326-mutilities">MUtilities</a>, which also has similar functionalities (plus some other goodies).</p><h3 id="Limitations">Limitations</h3><p>Setting a figure window&#8217;s transparency requires using Java Run-time Engine (JRE) 1.6.0_10 (also called &#8220;Java 6 update 10&#8243;) or higher. This means that it&#8217;s supported on Matlab release 7.9 (R2009b) and higher by default, and on earlier releases using a JRE retrofit.</p><p>If you are using an earlier Matlab release, consider a retrofit of JRE 1.6.0_10 or any later version (e.g., the latest available version today is 1.6 update 24). The JRE can be downloaded from <a
target="_blank" rel="nofollow" href="http://java.com/en/download/manual.jsp">here</a>, and you can configure Matlab to use it according to the instructions <a
target="_blank" rel="nofollow" href="http://www.mathworks.com/support/solutions/en/data/1-1812J/">here</a>. As noted, Matlab R2009b (7.9) and onward, at least on Microsoft Windows, pre-bundle a JRE version that does support transparency/opacity and so do not require a retrofit.</p><p>You can check your current Java version in Matlab as follows:</p><div
class="wp_syntax"><div
class="code"><pre class="text" style="font-family:monospace;">&gt;&gt; version -java
ans =
Java 1.6.0_17-b04 with Sun Microsystems Inc. Java HotSpot(TM) Client VM mixed mode</pre></div></div><p>Unfortunately, Matlab plot axes cannot be made transparent. If you have any axes in your GUI, the axes area will simply appear as a shaded axes, whose intensity depends on the selected alpha (transparency) value; the contents beneath the window will not be merged in the axes area as it is in the non-axes areas.</p><p>Finally, note that <code>com.sun.awt.AWTUtilities</code> is itself an undocumented Java class. It is bundled with the standard Java release since 2008 (1.6.0_10), and yet is not part of the official release because its API has not yet settled. In fact, in the upcoming Java 7 release, which is expected in a few months, and which I expect to be available in Matlab sometime in 2012, the set of transparency/opacity methods have <a
target="_blank" rel="nofollow" href="http://www.pushing-pixels.org/2009/05/03/translucent-and-shaped-windows-in-jdk-7.html">migrated</a> to the fully-documented <code>java.awt.Window</code> class.</p><h3 id="blurring">Blurred figure window</h3><p>So here&#8217;s a riddle for you: using figure window transparency, can you guess how to make a Matlab figure appear blurred for <a
target="_blank" href="http://undocumentedmatlab.com/blog/disable-entire-figure-window/">disabled figures</a> (see the screenshot there)? There are several possible ways to do this &#8211; can you find the simplest? The first one to <a
target="_blank" href="http://undocumentedmatlab.com/blog/transparent-matlab-figure-window/#respond">post a comment</a> with a correct answer gets a smiley&#8230; My answer will appear in next week&#8217;s article.</p><h3 id="upgrade">Upgraded website</h3><p>Also, did you notice my new website design? It&#8217;s supposed to be much more readable (yes &#8211; also on <a
target="_blank" rel="nofollow" href="http://blogs.mathworks.com/desktop/2010/05/24/introducing-matlab-mobile-%E2%80%93-an-iphone-app-to-connect-remotely-to-your-matlab/#comments">Android</a>&#8230;). It now also runs on a multi-server cloud, which means more stability and faster response times. Do you like the new design? hate it? I would love to hear your feedback via <a
target="_blank" href="http://undocumentedmatlab.com/blog/transparent-matlab-figure-window/#respond">comment</a> or <a
href="mailto:%20altmany%20@gmail.com?subject=Undocumented%20Matlab&amp;body=Hi%20Yair,%20&amp;cc=;&amp;bcc=" rel="nofollow" target="_blank" onclick="var n='altmany'; var d='gmail.com'; window.open('mailto:'+n+'@'+d+'?subject=Undocumented Matlab&amp;body=Hi Yair, '); return false;">email</a>.</p><p><pre> </pre>Related posts:<ol><li><a
href='http://undocumentedmatlab.com/blog/blurred-matlab-figure-window/' rel='bookmark' title='Blurred Matlab figure window'>Blurred Matlab figure window</a> <small>Matlab figure windows can be blurred using a semi-transparent overlaid window - this article explains how...</small></li><li><a
href='http://undocumentedmatlab.com/blog/minimize-maximize-figure-window/' rel='bookmark' title='Minimize/maximize figure window'>Minimize/maximize figure window</a> <small>Matlab figure windows can easily be maximized, minimized and restored using a bit of undocumented magic powder...</small></li><li><a
href='http://undocumentedmatlab.com/blog/disable-entire-figure-window/' rel='bookmark' title='Enable/disable entire figure window'>Enable/disable entire figure window</a> <small>Disabling/enabling an entire figure window is impossible with pure Matlab, but is very simple using the underlying Java. This article explains how....</small></li><li><a
href='http://undocumentedmatlab.com/blog/detecting-window-focus-events/' rel='bookmark' title='Detecting window focus events'>Detecting window focus events</a> <small>Matlab does not have any documented method to detect window focus events (gain/loss). This article describes an undocumented way to detect such events....</small></li></ol></p><pre> </pre>]]></content:encoded> <wfw:commentRss>http://undocumentedmatlab.com/blog/transparent-matlab-figure-window/feed/</wfw:commentRss> <slash:comments>5</slash:comments> </item> <item><title>Enable/disable entire figure window</title><link>http://undocumentedmatlab.com/blog/disable-entire-figure-window/</link> <comments>http://undocumentedmatlab.com/blog/disable-entire-figure-window/#comments</comments> <pubDate>Wed, 06 Apr 2011 18:00:20 +0000</pubDate> <dc:creator>Yair Altman</dc:creator> <category><![CDATA[Figure window]]></category> <category><![CDATA[GUI]]></category> <category><![CDATA[Hidden property]]></category> <category><![CDATA[Java]]></category> <category><![CDATA[Medium risk of breaking in future versions]]></category> <category><![CDATA[Internal component]]></category> <category><![CDATA[JavaFrame]]></category><guid
isPermaLink="false">http://undocumentedmatlab.com/?p=2089</guid> <description><![CDATA[Disabling/enabling an entire figure window is impossible with pure Matlab, but is very simple using the underlying Java. This article explains how.<pre> </pre>Related posts:<ol><li><a
href='http://undocumentedmatlab.com/blog/minimize-maximize-figure-window/' rel='bookmark' title='Minimize/maximize figure window'>Minimize/maximize figure window</a> <small>Matlab figure windows can easily be maximized, minimized and restored using a bit of undocumented magic powder...</small></li><li><a
href='http://undocumentedmatlab.com/blog/transparent-matlab-figure-window/' rel='bookmark' title='Transparent Matlab figure window'>Transparent Matlab figure window</a> <small>Matlab figure windows can be made fully or partially transparent/translucent or blurred - this article explains how...</small></li><li><a
href='http://undocumentedmatlab.com/blog/blurred-matlab-figure-window/' rel='bookmark' title='Blurred Matlab figure window'>Blurred Matlab figure window</a> <small>Matlab figure windows can be blurred using a semi-transparent overlaid window - this article explains how...</small></li><li><a
href='http://undocumentedmatlab.com/blog/detecting-window-focus-events/' rel='bookmark' title='Detecting window focus events'>Detecting window focus events</a> <small>Matlab does not have any documented method to detect window focus events (gain/loss). This article describes an undocumented way to detect such events....</small></li></ol><pre> </pre>]]></description> <content:encoded><![CDATA[<p>Some time ago, a reader on the CSSM newsgroup <a
target="_blank" rel="nofollow" href="http://www.mathworks.com/matlabcentral/newsreader/view_thread/300200">asked</a> whether it is possible to disable an entire figure window while some processing is taking place. Last week, Mike posted an article about the built-in functions <b><i>uiwait</i></b> and <b><i>uiresume</i></b> on <a
rel="nofollow" target="_blank" href="http://blogs.mathworks.com/desktop/2011/03/28/using-uiwaituiresume-to-control-program-flow/">MathWork&#8217;s Matlab Desktop blog</a>, which more-or-less answers this need. Today I will expand the answer based on several undocumented/unsupported mechanisms.</p><h3 id="uiwait">Uiwait and uiresume</h3><p>We start with a short review of the supported mechanism: We can use the built-in <b><i>uiwait</i></b> function to suspend Matlab processing until either the specified handle (typically a figure handle) is deleted/closed, a user callback programmatically calls <b><i>uiresume</i></b>, or Ctrl-C is pressed. A short example, adapted from <b><i>uiwait</i></b>&#8216;s help section (the official help section has a bug, so if anyone reads this at TMW, please fix):</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">h = <span style="color: #0000FF;">uicontrol</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'Position'</span>, <span style="color: #080;">&#91;</span><span style="color: #33f;">20</span> <span style="color: #33f;">20</span> <span style="color: #33f;">200</span> <span style="color: #33f;">40</span><span style="color: #080;">&#93;</span>, <span style="color:#A020F0;">'String'</span>, <span style="color:#A020F0;">'Continue'</span>, <span style="color:#A020F0;">'Callback'</span>, <span style="color:#A020F0;">'uiresume(gcbf)'</span><span style="color: #080;">&#41;</span>;
f = <span style="color: #0000FF;">gcf</span>;
<span style="color: #0000FF;">disp</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'This will print immediately'</span><span style="color: #080;">&#41;</span>;
uiwait<span style="color: #080;">&#40;</span>f<span style="color: #080;">&#41;</span>; 
<span style="color: #0000FF;">disp</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'This will print after you click Continue or close the window'</span><span style="color: #080;">&#41;</span>;
&nbsp;
<span style="color: #228B22;">% Close the figure (use try-catch in case f is already closed)</span>
<span style="color: #0000FF;">try</span> <span style="color: #0000FF;">close</span><span style="color: #080;">&#40;</span>f<span style="color: #080;">&#41;</span>; <span style="color: #0000FF;">catch</span>, <span style="color: #0000FF;">end</span></pre></div></div><p>Unfortunately, the side effect is that <b><i>uiwait</i></b> blocks the regular (non-callback&#8217;ed) processing until the lock is released. This is great for simple cases where we require a user to respond to a popup window (e.g., message-box or input dialog) before being allowed to proceed. In more complex situations we may wish to suspend interaction on certain figure windows while continuing to process Matlab functionality &#8211; this is impossible to do using <b><i>uiwait</i></b>.</p><p>Matlab does not have any documented way to disable an entire figure window. You can set the figure&#8217;s <a
target="_blank" rel="nofollow" href="http://www.mathworks.com/help/techdoc/ref/figure_props.html#WindowStyle"><b>WindowStyle</b> property</a> to &#8216;modal&#8217; but this is not the same: (1) it removes the toolbar and menu-bar (2) it still enables interaction with all the figure&#8217;s GUI controls and (3) it prevents access to any other Matlab window or desktop until the modal figure is closed. This is certainly NOT what we need.</p><p>Of course, we could always loop over all the relevant GUI handles and set their <a
target="_blank" rel="nofollow" href="http://www.mathworks.com/help/techdoc/ref/uicontrol_props.html#Enable"><b>Enable</b> property</a> to &#8216;inactive&#8217; or &#8216;off&#8217;. But this is tedious, lengthy, and in complex GUIs that have multiple layers of nested panels, it also requires careful recursive programming. We also need to take care to disable hidden handles, toolbars, menu-bars, context-menus, Java components &#8211; all these have different ways of being accessed and disabled. And once we <b><i>uiresume</i></b> from the lock, we need to remember each handle&#8217;s pre-<b><i>uiwait</i></b> state, so that if it was disabled before the call to <b><i>uiwait</i></b>, it will remain so after <b><i>uiresume</i></b>. In short, this is not a trivial exercise at all.</p><h3 id="uisuspend">Uisuspend and uirestore</h3><p>To complicate things, the fully-documented and supported <b><i>uiwait</i></b> and <b><i>uiresume</i></b> functions have the <a
target="_blank" href="http://undocumentedmatlab.com/blog/legend-semi-documented-feature/#Semi-documented">semi-documented</a> unsupported built-in counterparts <b><i>uisuspend</i></b> and <b><i>uirestore</i></b>, which are very similar in functionality and name. It is important not to confuse between these two function sets, and most importantly, not to confuse between <b><i>uiresume</i></b> and <b><i>uirestore</i></b> after using their counterparts earlier in the code – odd things might happen if you do&#8230;</p><p>Hopefully, in a nearby Matlab release these inconsistencies between the two function sets will disappear and they will be merged, because the current situation is prone to errors and confusion. For backward compatibility considerations, I hope that <b><i>uisuspend</i></b> and <b><i>uirestore</i></b> would not be discontinued but rather be modified to simply call <b><i>uiwait</i></b> and <b><i>uiresume</i></b>.</p><p>Note that in Matlab releases up to R2010b, <b><i>uirestore</i></b> had a <a
rel="nofollow" target="_blank" href="http://www.mathworks.com/support/bugreports/646025 ">minor bug</a> in that it overwrites the figure&#8217;s <b>WindowScrollWheelFcn</b> callback with the <b>WindowKeyPressFcn</b> value. This bug was finally fixed in R2011a.</p><h3 id="Method">How to enable/disable a figure window</h3><p>So going back to the main question, we want to find a way to disable an entire figure window, in one simple stroke, and without blocking the Matlab processing.</p><p>As usual, we turn to Java and the solution is trivially simple:</p><p>First, get the figure window&#8217;s underlying Java reference. Note that we need the top-level container reference, rather than the proxy peer handle returned by the <b>JavaFrame</b> hidden property:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">&gt;&gt; jFigPeer = <span style="color: #0000FF;">get</span><span style="color: #080;">&#40;</span>handle<span style="color: #080;">&#40;</span><span style="color: #0000FF;">gcf</span><span style="color: #080;">&#41;</span>,<span style="color:#A020F0;">'JavaFrame'</span><span style="color: #080;">&#41;</span>
jFigPeer =
com.<span style="">mathworks</span>.<span style="">hg</span>.<span style="">peer</span>.<span style="">FigurePeer</span>@1ffbad6
&nbsp;
&gt;&gt; jWindow = jFigPeer.<span style="">fFigureClient</span>.<span style="">getWindow</span>
<span style="color: #0000FF;">ans</span> =
com.<span style="">mathworks</span>.<span style="">hg</span>.<span style="">peer</span>.<span style="">FigureFrameProxy</span>$FigureFrame<span style="color: #080;">&#91;</span><span style="color: #F0F;">...</span><span style="color: #080;">&#93;</span></pre></div></div><p>Now remember that all Java GUI components (on which Matlab GUI is based) contain an <a
target="_blank" rel="nofollow" href="http://download.oracle.com/javase/6/docs/api/java/awt/Component.html#setEnabled%28boolean%29"><b>Enabled</b> property</a>. So, simply set this property on the jWindow reference to true or false:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">jWindow.<span style="">setEnabled</span><span style="color: #080;">&#40;</span><span style="color: #0000FF;">false</span><span style="color: #080;">&#41;</span>;  <span style="color: #228B22;">% or true</span>
&nbsp;
<span style="color: #228B22;">% an equivalent alternative</span>
<span style="color: #0000FF;">set</span><span style="color: #080;">&#40;</span>handle<span style="color: #080;">&#40;</span>jWindow<span style="color: #080;">&#41;</span>,<span style="color:#A020F0;">'Enabled'</span>,<span style="color: #0000FF;">false</span><span style="color: #080;">&#41;</span>  <span style="color: #228B22;">% or true</span></pre></div></div><p>By the way, if you only need to disable the figure&#8217;s content area (i.e., not the toolbar and menu bar), simply use a different reference handle:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">jFigPeer.<span style="">getFigurePanelContainer</span>.<span style="">setEnabled</span><span style="color: #080;">&#40;</span><span style="color: #0000FF;">false</span><span style="color: #080;">&#41;</span>;  <span style="color: #228B22;">% or true</span></pre></div></div><p>Notes:</p><ul><li>While the window looks the same when it is disabled, in reality none of its GUI elements can be clicked or activated (try it!). If you also want the figure to appear blurred you could try using something like a <a
target="_blank" rel="nofollow" href="http://java.net/projects/jxlayer/">JXLayer</a> semi-translucent glass pane.</li><li>The Java components&#8217; property is called <b>Enabled</b>, not <b>Enable</b> as in pure-Matlab Handle-Graphics controls. Also, the Java property expects true/false (or 0/1), rather than Matlab&#8217;s &#8216;on&#8217;/'off&#8217; (there are some fine details here that are release-specific so I will skip them)</li><li>For docked windows the top-level window is the figure&#8217;s group container window or the desktop window, which we do not want to disable. Detecting this is easy (check whether the figure&#8217;s <b>WindowStyle</b> is &#8216;docked&#8217;), and in such cases simply disable/enable the figure&#8217;s content area as shown above.</li></ul><h3 id="JavaFrame">Use of the JavaFrame property</h3><p>Note that all this relies on the undocumented hidden figure property <b>JavaFrame</b>, which issues a standing warning (since Matlab release R2008a) of becoming obsolete in some future Matlab release (HG2?):</p><div
class="wp_syntax"><div
class="code"><pre style="font-family: monospace;"><span style="color: #000000;">>> jFigPeer = </span><span style="color: #0000ff;">get</span>(<span style="color: #0000ff;">gcf</span>,<span style="color: #800080;">'JavaFrame'</span>)
<span style="color: #ff0000;">Warning: figure JavaFrame property will be obsoleted in a future release.</span>
<span style="color: #000000;">For more information see the JavaFrame resource on the MathWorks web site.
(Type "warning off MATLAB:HandleGraphics:ObsoletedProperty:JavaFrame"
to suppress this warning.) 

jFigPeer =
com.mathworks.hg.peer.FigurePeer@1ffbad6</span>
</div>
</div>
</pre><p>To remove the above warning I have used (note the <i><b>handle</b></i> wrapper, as <a
target="_blank" href="http://undocumentedmatlab.com/blog/detecting-window-focus-events/#comment-2756">suggested</a> by Donn Shull):</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">jFigPeer = <span style="color: #0000FF;">get</span><span style="color: #080;">&#40;</span>handle<span style="color: #080;">&#40;</span><span style="color: #0000FF;">gcf</span><span style="color: #080;">&#41;</span>,<span style="color:#A020F0;">'JavaFrame'</span><span style="color: #080;">&#41;</span></pre></div></div><p>If and when <b>JavaFrame</b> does become obsolete in some future Matlab version, be sure to look in this blog for workarounds.</p><p>You may also wish to inform MathWorks on the dedicated webpage that they have set up for specifically this reason (<a
target="_blank" rel="nofollow" href="http://www.mathworks.com/javaframe">http://www.mathworks.com/javaframe</a>), how you are using <b>JavaFrame</b> and why it is important for you. This may help them to decide whether to keep <b>JavaFrame</b> or possibly add the functionality using other means.</p><h3 id="enableDisableFig">The enableDisableFig utility</h3><p>In 2007, I created the <a
target="_blank" rel="nofollow" href="http://www.mathworks.com/matlabcentral/fileexchange/15895-enabledisable-figure"><i><b>enableDisableFig</b></i> utility</a> that wraps the above code in an easy-to-use Matlab utility that I have uploaded to the File Exchange.</p><p><i><b>enableDisableFig</b></i> returns the current state of the specified figure handle (or <i><b>gcf</b></i> if no handle is specified), and optionally sets the figure&#8217;s enabled/disabled state to a new value (&#8216;on&#8217;,'off&#8217;, true or false):</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">&gt;&gt; oldState = enableDisableFig<span style="color: #080;">&#40;</span><span style="color: #0000FF;">gcf</span>, <span style="color:#A020F0;">'on'</span><span style="color: #080;">&#41;</span>
oldState =
on
&nbsp;
&gt;&gt; enableDisableFig<span style="color: #080;">&#40;</span>oldState<span style="color: #080;">&#41;</span>;
&gt;&gt; enableDisableFig<span style="color: #080;">&#40;</span><span style="color: #0000FF;">true</span><span style="color: #080;">&#41;</span>;  <span style="color: #228B22;">% an alternative</span></pre></div></div><p><i><b>enableDisableFig</b></i> also provides some sanity checks and error handling that should always appear in any real-world application. In this blog I generally tend to provide only bare-bones code snippets (as above). But in any respected application we must check the validity of input arguments and return values, catch run-time errors, compensate for incompatibilities with older Matlab release and so on. Take a look at <i><b>enableDisableFig</b></i>&#8216;s source code to see how I have done this.</p><h3 id="visual">Visual aid</h3><p>When any GUI control is disabled, the accepted convention is to shade it in a gray color as a visual aid to the user that the control is currently disabled. This is automatically done by Matlab when any control&#8217;s <b>Enable</b> property is set to &#8216;off&#8217;. In our case, it would be very helpful to display a similar blurring effect for the disabled figure window.</p><p>Would you be very surprised if I told you that this is impossible to do with regular Matlab, but trivially easy to achieve using a tiny bit of Java magic powder? I&#8217;ll expand on this in my next post, but here&#8217;s something to keep you waiting:</p><p><center><div
class="wp-caption aligncenter" style="width: 460px"><img
alt="A blurred disabled figure" src="http://UndocumentedMatlab.com/images/blurFigure.png" title="A blurred disabled figure" width="450" /><p
class="wp-caption-text">A blurred disabled figure</p></div></center></p><h3 id="upgrade">Server upgrade</h3><p>This weekend (9-10 April, 2011) I plan to upgrade the website. This will entail moving to a different webserver, database, upgraded blogging application, new design etc. This site may be down or &#8220;goofy&#8221; for quite a few hours. Hopefully all will be back to normal by Monday and I hope you will like the new design.</p><p><pre> </pre>Related posts:<ol><li><a
href='http://undocumentedmatlab.com/blog/minimize-maximize-figure-window/' rel='bookmark' title='Minimize/maximize figure window'>Minimize/maximize figure window</a> <small>Matlab figure windows can easily be maximized, minimized and restored using a bit of undocumented magic powder...</small></li><li><a
href='http://undocumentedmatlab.com/blog/transparent-matlab-figure-window/' rel='bookmark' title='Transparent Matlab figure window'>Transparent Matlab figure window</a> <small>Matlab figure windows can be made fully or partially transparent/translucent or blurred - this article explains how...</small></li><li><a
href='http://undocumentedmatlab.com/blog/blurred-matlab-figure-window/' rel='bookmark' title='Blurred Matlab figure window'>Blurred Matlab figure window</a> <small>Matlab figure windows can be blurred using a semi-transparent overlaid window - this article explains how...</small></li><li><a
href='http://undocumentedmatlab.com/blog/detecting-window-focus-events/' rel='bookmark' title='Detecting window focus events'>Detecting window focus events</a> <small>Matlab does not have any documented method to detect window focus events (gain/loss). This article describes an undocumented way to detect such events....</small></li></ol></p><pre> </pre>]]></content:encoded> <wfw:commentRss>http://undocumentedmatlab.com/blog/disable-entire-figure-window/feed/</wfw:commentRss> <slash:comments>5</slash:comments> </item> <item><title>UDD Properties</title><link>http://undocumentedmatlab.com/blog/udd-properties/</link> <comments>http://undocumentedmatlab.com/blog/udd-properties/#comments</comments> <pubDate>Wed, 09 Mar 2011 18:00:17 +0000</pubDate> <dc:creator>Yair Altman</dc:creator> <category><![CDATA[Guest bloggers]]></category> <category><![CDATA[Hidden property]]></category> <category><![CDATA[Medium risk of breaking in future versions]]></category> <category><![CDATA[Stock Matlab function]]></category> <category><![CDATA[Undocumented feature]]></category> <category><![CDATA[Donn Shull]]></category> <category><![CDATA[Pure Matlab]]></category> <category><![CDATA[schema]]></category> <category><![CDATA[schema.prop]]></category> <category><![CDATA[Undocumented property]]></category><guid
isPermaLink="false">http://undocumentedmatlab.com/?p=2156</guid> <description><![CDATA[UDD provides a very convenient way to add customizable properties to existing Matlab object handles<pre> </pre>Related posts:<ol><li><a
href='http://undocumentedmatlab.com/blog/getundoc-get-undocumented-object-properties/' rel='bookmark' title='getundoc &#8211; get undocumented object properties'>getundoc &#8211; get undocumented object properties</a> <small>getundoc is a very simple utility that displays the hidden (undocumented) properties of a specified handle object....</small></li><li><a
href='http://undocumentedmatlab.com/blog/plot-liminclude-properties/' rel='bookmark' title='Plot LimInclude properties'>Plot LimInclude properties</a> <small>The plot objects' XLimInclude, YLimInclude, ZLimInclude, ALimInclude and CLimInclude properties are an important feature, that has both functional and performance implications....</small></li><li><a
href='http://undocumentedmatlab.com/blog/displaying-hidden-handle-properties/' rel='bookmark' title='Displaying hidden handle properties'>Displaying hidden handle properties</a> <small>I present two ways of checking undocumented hidden properties in Matlab Handle Graphics (HG) handles...</small></li><li><a
href='http://undocumentedmatlab.com/blog/borderless-button-used-for-plot-properties/' rel='bookmark' title='Borderless button used for plot properties'>Borderless button used for plot properties</a> <small>A borderless button can be used to add unobtrusive functionality to plot axes...</small></li></ol><pre> </pre>]]></description> <content:encoded><![CDATA[<p><i>Donn Shull continues his series of articles on Matlab&#8217;s undocumented UDD mechanism. Today, Donn explains how to use and customize UDD properties.</i></p><h3 id="meta-data">Properties meta-data</h3><p>The UDD system is a class system. UDD packages, classes, events, and properties are all classes. In this section we will take a closer look at property classes.</p><p>As we have <a
target="_blank" href="http://undocumentedmatlab.com/blog/creating-a-simple-udd-class/">already shown</a>, properties are added to a UDD class by adding <code>schema.prop</code> calls to the schema.m class definition file. What this really means is that each property of a UDD class is itself a class object (<code>schema.prop</code>) with its own properties and methods. The methods of <code>schema.prop</code> are <i>loadobj()</i> and <i>saveobj()</i>, which are used to serialize objects of this class (i.e., storing them in a file or sending them elsewhere).</p><p>It is <code>schema.prop</code>&#8216;s properties (so-called <i>meta-properties</i>) that interest us most:</p><table><tr><th
bgcolor="#D0D0D0">Property</th><th
bgcolor="#D0D0D0">Data Type</th><th
bgcolor="#D0D0D0">Description</th></tr><tr><td
bgcolor="#E7E7E7">AccessFlags</td><td
bgcolor="#E7E7E7">Matlab structure</td><td
bgcolor="#E7E7E7">Controls which objects can access (read/modify) the property</td></tr><tr><td
bgcolor="#E7E7E7">CaseSensitive</td><td
bgcolor="#E7E7E7">on/off</td><td
bgcolor="#E7E7E7">Determines if the exact case is required to access the property (i.e., can we use &#8216;casesensitive&#8217; instead of &#8216;CaseSensitive&#8217;)</td></tr><tr><td
bgcolor="#E7E7E7">DataType</td><td
bgcolor="#E7E7E7">string</td><td
bgcolor="#E7E7E7">The underlying object&#8217;s property data type, set by the constructor</td></tr><tr><td
bgcolor="#E7E7E7">Description</td><td
bgcolor="#E7E7E7">string</td><td
bgcolor="#E7E7E7">This can hold a description of the property (normally empty)</td></tr><tr><td
bgcolor="#E7E7E7">FactoryValue</td><td
bgcolor="#E7E7E7">As specified by DataType</td><td
bgcolor="#E7E7E7">This is used to provide an initial or default property value</td></tr><tr><td
bgcolor="#E7E7E7">GetFunction</td><td
bgcolor="#E7E7E7">Function handle</td><td
bgcolor="#E7E7E7">A function handle that is called whenever the property value is read</td></tr><tr><td
bgcolor="#E7E7E7">Name</td><td
bgcolor="#E7E7E7">string</td><td
bgcolor="#E7E7E7">The name of the property, also set by the constructor</td></tr><tr><td
bgcolor="#E7E7E7">SetFunction</td><td
bgcolor="#E7E7E7">Function handle</td><td
bgcolor="#E7E7E7">A function handle that is called whenever the properties value is changed</td></tr><tr><td
bgcolor="#E7E7E7">Visible</td><td
bgcolor="#E7E7E7">on/off</td><td
bgcolor="#E7E7E7">Determines if a property will be displayed by the <i><b>get</b></i> method for a UDD object</td></tr></table><p>We can manipulate the values of these meta-properties to control various aspects of our property:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;"><span style="color: #228B22;">% Create instance of simple.object</span>
&gt;&gt; a = simple.<span style="">object</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'a'</span><span style="color: #080;">&#41;</span>;
&nbsp;
<span style="color: #228B22;">% Find the Value property and list its meta-properties</span>
<span style="color: #228B22;">% We can manipulate these meta-properties within limits</span>
&gt;&gt; a.<span style="color: #0000FF;">findprop</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'Value'</span><span style="color: #080;">&#41;</span>.<span style="color: #0000FF;">get</span>
            Name<span style="color: #F0F;">:</span> <span style="color:#A020F0;">'Value'</span>
     Description<span style="color: #F0F;">:</span> <span style="color:#A020F0;">''</span>
        DataType<span style="color: #F0F;">:</span> <span style="color:#A020F0;">'single'</span>
    FactoryValue<span style="color: #F0F;">:</span> <span style="color: #33f;">7.3891</span>
     AccessFlags<span style="color: #F0F;">:</span> <span style="color: #080;">&#91;</span>1x1 <span style="color: #0000FF;">struct</span><span style="color: #080;">&#93;</span>
         Visible<span style="color: #F0F;">:</span> <span style="color:#A020F0;">'on'</span>
     GetFunction<span style="color: #F0F;">:</span> <span style="color: #080;">&#91;</span><span style="color: #080;">&#93;</span>
     SetFunction<span style="color: #F0F;">:</span> <span style="color: #080;">&#91;</span><span style="color: #080;">&#93;</span>
&nbsp;
&gt;&gt; prop.<span style="">Visible</span> = <span style="color:#A020F0;">'off'</span>;  <span style="color: #228B22;">% i.e. hidden property (see below)</span>
&gt;&gt; prop.<span style="">AccessFlags</span>.<span style="">PublicSet</span> = <span style="color:#A020F0;">'off'</span>;   <span style="color: #228B22;">% i.e. read-only</span>
&gt;&gt; prop.<span style="">AccessFlags</span>.<span style="">PublicGet</span> = <span style="color:#A020F0;">'on'</span>;
&nbsp;
<span style="color: #228B22;">% Find the DataType meta-property of the Value property</span>
<span style="color: #228B22;">% This meta-property and all other schema.prop base class properties are fixed</span>
&gt;&gt; a.<span style="color: #0000FF;">findprop</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'Value'</span><span style="color: #080;">&#41;</span>.<span style="color: #0000FF;">findprop</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'DataType'</span><span style="color: #080;">&#41;</span>.<span style="color: #0000FF;">get</span>
            Name<span style="color: #F0F;">:</span> <span style="color:#A020F0;">'DataType'</span>
     Description<span style="color: #F0F;">:</span> <span style="color:#A020F0;">''</span>
        DataType<span style="color: #F0F;">:</span> <span style="color:#A020F0;">'string'</span>
    FactoryValue<span style="color: #F0F;">:</span> <span style="color:#A020F0;">''</span>
           <span style="color: #F0F;">...</span></pre></div></div><h3 id="new-prop">Adding properties to existing objects in run-time</h3><p><code>schema.prop</code> is a very useful tool &#8211; it can be used to add new properties to existing object handles, even after these objects have been created. For example, let&#8217;s add a new property (<b>MyFavoriteBlog</b>) to a standard figure handle:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">&gt;&gt; p=schema.<span style="">prop</span><span style="color: #080;">&#40;</span>handle<span style="color: #080;">&#40;</span><span style="color: #0000FF;">gcf</span><span style="color: #080;">&#41;</span>, <span style="color:#A020F0;">'MyFavoriteBlog'</span>,<span style="color:#A020F0;">'string'</span><span style="color: #080;">&#41;</span>
p =
	schema.<span style="">prop</span>
&nbsp;
&gt;&gt; <span style="color: #0000FF;">set</span><span style="color: #080;">&#40;</span><span style="color: #0000FF;">gcf</span>,<span style="color:#A020F0;">'MyFavoriteBlog'</span>,<span style="color:#A020F0;">'UndocumentedMatlab.com'</span><span style="color: #080;">&#41;</span>
&nbsp;
&gt;&gt; <span style="color: #0000FF;">get</span><span style="color: #080;">&#40;</span><span style="color: #0000FF;">gcf</span>,<span style="color:#A020F0;">'MyFavoriteBlog'</span><span style="color: #080;">&#41;</span>
<span style="color: #0000FF;">ans</span> =
UndocumentedMatlab.<span style="">com</span></pre></div></div><p>Using this simple mechanism, we can add meaningful typed user data to any handle object. A similar functionality can be achieved via the <i><b>setappdata/getappdata</b></i> functions. However, the property-based approach above is much &#8220;cleaner&#8221; and more powerful, since we have built-in type checks, property-change event listeners and other useful goodies.</p><h3 id="DataType">Property data types</h3><p>In the article on <a
target="_blank" href="http://undocumentedmatlab.com/blog/creating-a-simple-udd-class/">creating UDD objects</a> we saw that the <b>Name</b> and <b>DataType</b> meta-properties are set by the <code>schema.prop</code> constructor. <b>Name</b> must be a valid Matlab variable name (see <i><b>isvarname</b></i>).</p><p><b>DataType</b> is more interesting: There are two equivalent universal data types, <code>'mxArray'</code>, and <code>'MATLAB array'</code>. With either of these two data types a property can be set to a any Matlab type. If we use a more specific data type (e.g., &#8216;string&#8217;, &#8216;double&#8217; or &#8216;handle&#8217;), Matlab automatically ensures the type validity whenever the property value is modified. In our <code>simple.object</code> we use &#8216;double&#8217; and &#8216;string&#8217;. You can experiment with these and see that the <b>Value</b> property will only allow scalar numeric values and the <b>Name</b> property will only allow character values:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">&gt;&gt; <span style="color: #0000FF;">set</span><span style="color: #080;">&#40;</span>obj, <span style="color:#A020F0;">'Value'</span>, <span style="color:#A020F0;">'abcd'</span><span style="color: #080;">&#41;</span>
??? Parameter must be scalar.
&nbsp;
&gt;&gt; obj.<span style="">Value</span>=<span style="color:#A020F0;">'abcd'</span>
??? Parameter must be scalar.
&nbsp;
&gt;&gt; obj.<span style="">Name</span>=<span style="color: #33f;">123</span>
??? Parameter must be a string.</pre></div></div><p>The following table lists the basic UDD data types:</p><table><tr><th
bgcolor="#D0D0D0">Category</th><th
bgcolor="#D0D0D0">Data Type</th></tr><tr><td
bgcolor="#E7E7E7">Universal</td><td
bgcolor="#E7E7E7">MATLAB array, mxArray</td></tr><tr><td
bgcolor="#E7E7E7">Numeric Scalars</td><td
bgcolor="#E7E7E7">bool, byte, short, int, long, float, double</td></tr><tr><td
bgcolor="#E7E7E7">Numeric Vectors</td><td
bgcolor="#E7E7E7">Nints, NReals</td></tr><tr><td
bgcolor="#E7E7E7">Specialized Numeric</td><td
bgcolor="#E7E7E7">color, point, real point, real point3, rect, real rect</td></tr><tr><td
bgcolor="#E7E7E7">Enumeration</td><td
bgcolor="#E7E7E7">on/off</td></tr><tr><td
bgcolor="#E7E7E7">Strings</td><td
bgcolor="#E7E7E7">char, string, NStrings, string vector</td></tr><tr><td
bgcolor="#E7E7E7">Handle</td><td
bgcolor="#E7E7E7">handle, handle vector, MATLAB callback, GetFunction, SetFunction</td></tr><tr><td
bgcolor="#E7E7E7">Java</td><td
bgcolor="#E7E7E7">Any java class recognized by Matlab</td></tr></table><h3 id="user-types">User-defined data types</h3><p>While this is an extensive list, there are some obvious types missing. For example there are no unsigned integer types. To handle this UDD provides two facilities for creating your own data types. One is the <code>schema.EnumType</code>. As you can see, Matlab has had a form of enumerations for a really long time not just the last few releases. The other facility is <code>schema.UserType</code>.</p><p>With these two classes you can create any specialized data type you need. One word of caution: once you have created a new UDD data type it exists for the duration of that Matlab session. There is no equivalent of the <i><b>clear classes</b></i> mechanism for removing a data type. In addition once a new data type has been defined it cannot be redefined until Matlab is restarted.</p><p>Let&#8217;s use a <a
target="_blank" rel="nofollow" href="http://www.mathworks.com/matlabcentral/newsreader/view_thread/280282">problem discussed in the CSSM forum</a> as example. The essence of the problem is the need to flag a graphic line object as either editable or not. The proposed proposed is to add a new <b>Editable</b> property to an existing line handle. We will use <code>schema.EnumType</code> to create a new type named <code>'yes/no'</code> so that the new property could accept only &#8216;yes&#8217; and &#8216;no&#8217; values:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;"><span style="color: #0000FF;">function</span> tline = taggedLine<span style="color: #080;">&#40;</span><span style="color: #0000FF;">varargin</span><span style="color: #080;">&#41;</span>
<span style="color: #228B22;">%TAGGEDLINE create a line with Editable property</span>
<span style="color: #228B22;">%</span>
<span style="color: #228B22;">%   TLINE = TAGGEDLINE(VARARGIN) create a new handle graphics line</span>
<span style="color: #228B22;">%   and add 'Ediatable' property to line. Default property value is 'yes'.</span>
<span style="color: #228B22;">%</span>
<span style="color: #228B22;">%   INPUTS:</span>
<span style="color: #228B22;">%       VARARGIN  : property value pairs to pass to line</span>
<span style="color: #228B22;">%</span>
<span style="color: #228B22;">%   OUTPUTS:</span>
<span style="color: #228B22;">%       TLINE     : hg line object with Editable property</span>
&nbsp;
    <span style="color: #228B22;">% If undefined define yes/no datatype&lt;/font&gt;</span>
    <span style="color: #0000FF;">if</span> <span style="color: #0000FF;">isempty</span><span style="color: #080;">&#40;</span>findtype<span style="color: #080;">&#40;</span><span style="color:#A020F0;">'yes/no'</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>
        schema.<span style="">EnumType</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'yes/no'</span>, <span style="color: #080;">&#123;</span><span style="color:#A020F0;">'yes'</span>, <span style="color:#A020F0;">'no'</span><span style="color: #080;">&#125;</span><span style="color: #080;">&#41;</span>;
    <span style="color: #0000FF;">end</span>
    tline = <span style="color: #0000FF;">line</span><span style="color: #080;">&#40;</span><span style="color: #0000FF;">varargin</span><span style="color: #080;">&#123;</span><span style="color: #F0F;">:</span><span style="color: #080;">&#125;</span><span style="color: #080;">&#41;</span>;
    schema.<span style="">prop</span><span style="color: #080;">&#40;</span>tline, <span style="color:#A020F0;">'Editable'</span>, <span style="color:#A020F0;">'yes/no'</span><span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">end</span></pre></div></div><p>It is necessary to test for the existence of a type before defining it, since trying to redefine a type will generate an error.</p><p>We can use this new <i>taggedLine()</i> function to create new line objects with the additional <b>Editable</b> property. Instead of adding a new property to the line class we could have defined a new class as a subclass of line:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;"><span style="color: #0000FF;">function</span> schema<span style="color: #080;">&#40;</span><span style="color: #080;">&#41;</span>
<span style="color: #228B22;">%SCHEMA  hg package definition function</span>
    schema.<span style="">package</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'hg'</span><span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">end</span></pre></div></div><p>We create our class definition as a subclass of the handle graphics line class:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;"><span style="color: #0000FF;">function</span> schema<span style="color: #080;">&#40;</span><span style="color: #080;">&#41;</span>
<span style="color: #228B22;">%SCHEMA  hg.taggedline class definition function</span>
    <span style="color: #228B22;">% package definition</span>
    superPackage = findpackage<span style="color: #080;">&#40;</span><span style="color:#A020F0;">'hg'</span><span style="color: #080;">&#41;</span>;
    pkg = findpackage<span style="color: #080;">&#40;</span><span style="color:#A020F0;">'hg'</span><span style="color: #080;">&#41;</span>;
&nbsp;
    <span style="color: #228B22;">% class definition</span>
    c = schema.<span style="color: #0000FF;">class</span><span style="color: #080;">&#40;</span>pkg, <span style="color:#A020F0;">'taggedline'</span>, findclass<span style="color: #080;">&#40;</span>superPackage, <span style="color:#A020F0;">'line'</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>;
&nbsp;
    <span style="color: #0000FF;">if</span> <span style="color: #0000FF;">isempty</span><span style="color: #080;">&#40;</span>findtype<span style="color: #080;">&#40;</span><span style="color:#A020F0;">'yes/no'</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>
        schema.<span style="">EnumType</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'yes/no'</span>, <span style="color: #080;">&#123;</span><span style="color:#A020F0;">'yes'</span>, <span style="color:#A020F0;">'no'</span><span style="color: #080;">&#125;</span><span style="color: #080;">&#41;</span>;
    <span style="color: #0000FF;">end</span>
&nbsp;
    <span style="color: #228B22;">% add properties to class</span>
    schema.<span style="">prop</span><span style="color: #080;">&#40;</span>c, <span style="color:#A020F0;">'Editable'</span>, <span style="color:#A020F0;">'yes/no'</span><span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">end</span></pre></div></div><p>And our constructor is:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;"><span style="color: #0000FF;">function</span> self = taggedline
<span style="color: #228B22;">%OBJECT constructor for the simple.object class</span>
    self = hg.<span style="">taggedline</span>;
<span style="color: #0000FF;">end</span></pre></div></div><p>Here we have placed the <code>schema.EnumType</code> definition in the class definition function. It is usually better to place type definition code in the package definition function, which is executed prior to any of the package classes and available in all classes. But in this particular case we are extending the built-in <code>hg</code> package and because <code>hg</code> is already defined internally, our package definition code is never actually executed.</p><p>The <code>schema.UserType</code> has the following constructor syntax:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">schema.<span style="">UserType</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'newTypeName'</span>, <span style="color:#A020F0;">'baseTypeName'</span>, typeCheckFunctionHandle<span style="color: #080;">&#41;</span></pre></div></div><p>For example, to create a user-defined type for unsigned eight-bit integers we might use the following code:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">schema.<span style="">UserType</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'uint8'</span>, <span style="color:#A020F0;">'short'</span>, @check_uint8<span style="color: #080;">&#41;</span>
&nbsp;
<span style="color: #0000FF;">function</span> check_uint8<span style="color: #080;">&#40;</span>value<span style="color: #080;">&#41;</span>
<span style="color: #228B22;">%CHECK_UINT8 Check function for uint8 type definition</span>
    <span style="color: #0000FF;">if</span> <span style="color: #0000FF;">isempty</span><span style="color: #080;">&#40;</span>value<span style="color: #080;">&#41;</span> <span style="color: #F0F;">||</span> <span style="color: #080;">&#40;</span>value &lt; <span style="color: #33f;">0</span><span style="color: #080;">&#41;</span> <span style="color: #F0F;">||</span> <span style="color: #080;">&#40;</span>value &gt; <span style="color: #33f;">255</span><span style="color: #080;">&#41;</span>
        <span style="color: #0000FF;">error</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'Value must be a scalar between 0 and 255'</span><span style="color: #080;">&#41;</span>;
    <span style="color: #0000FF;">end</span>
<span style="color: #0000FF;">end</span></pre></div></div><h3 id="hidden">Hidden properties</h3><p><b>Visible</b> is an <code>'on/off'</code> meta-property that controls whether or not a property is displayed when using the <i><b>get</b></i> function without specifying the property name. Using this mechanism we can easily detect hidden undocumented properties. For example:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">&gt;&gt; <span style="color: #0000FF;">for</span> prop = <span style="color: #0000FF;">get</span><span style="color: #080;">&#40;</span>classhandle<span style="color: #080;">&#40;</span>handle<span style="color: #080;">&#40;</span><span style="color: #0000FF;">gcf</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>,<span style="color:#A020F0;">'Properties'</span><span style="color: #080;">&#41;</span>'
       <span style="color: #0000FF;">if</span> <span style="color: #0000FF;">strcmpi</span><span style="color: #080;">&#40;</span>prop.<span style="">Visible</span>,<span style="color:#A020F0;">'off'</span><span style="color: #080;">&#41;</span>, <span style="color: #0000FF;">disp</span><span style="color: #080;">&#40;</span>prop.<span style="">Name</span><span style="color: #080;">&#41;</span>; <span style="color: #0000FF;">end</span>
   <span style="color: #0000FF;">end</span>
&nbsp;
BackingStore
CurrentKey
CurrentModifier
Dithermap
DithermapMode
DoubleBuffer
FixedColors
HelpFcn
HelpTopicMap
MinColormap
JavaFrame
OuterPosition
ActivePositionProperty
PrintTemplate
ExportTemplate
WaitStatus
UseHG2
PixelBounds
HelpTopicKey
Serializable
ApplicationData
Behavior
XLimInclude
YLimInclude
ZLimInclude
CLimInclude
ALimInclude
IncludeRenderer</pre></div></div><p>Note that hidden properties such as these are accessible via <i><b>get/set</b></i> just as any other property. It is simply that they are not displayed when you run <i><b>get(gcf)</b></i> or <i><b>set(gcf)</b></i> &#8211; we need to specifically refer to them by their name: <i><b>get(gcf</b>,&#8217;UseHG2&#8242;)</i>. Many other similar hidden properties are <a
target="_blank" href="http://undocumentedmatlab.com/blog/tag/hidden-property/">described in this website</a>.</p><p>You may have noticed that the <b>CaseSensitive</b> meta-property did not show up above when we used <i><b>get</b></i> to show the meta-properties of our <b>Value</b> property. This is because <b>CaseSensitive</b> has its own <b>Visible</b> meta-property set to <code>'off'</code> (i.e., hidden).</p><h3 id="additional">Additional meta-properties</h3><p><b>FactoryValue</b> is used to set an initial value for the property whenever a new <code>simple.object</code> instance is created.</p><p><b>GetFunction</b> and <b>SetFunction</b> were described in last week&#8217;s article, <a
href="http://undocumentedmatlab.com/blog/hierarchical-systems-with-udd/">Creating a UDD Hierarchy</a>.</p><p><b>AccessFlags</b> is a Matlab structure of <code>'on/off'</code> fields that control what happens when the property is accessed:</p><table><tr><th
bgcolor="#D0D0D0">Fieldname</th><th
bgcolor="#D0D0D0">Description</th></tr><tr><td
bgcolor="#E7E7E7">PublicSet</td><td
bgcolor="#E7E7E7">Controls setting the property from code external to the class</td></tr><tr><td
bgcolor="#E7E7E7">PublicGet</td><td
bgcolor="#E7E7E7">Controls reading the property value from code external to the class</td></tr><tr><td
bgcolor="#E7E7E7">PrivateSet</td><td
bgcolor="#E7E7E7">Controls setting the property from internal class methods</td></tr><tr><td
bgcolor="#E7E7E7">PrivateGet</td><td
bgcolor="#E7E7E7">Controls reading the property value from internal class methods</td></tr><tr><td
bgcolor="#E7E7E7">Init</td><td
bgcolor="#E7E7E7">Controls initializing the property using <b>FactoryValue</b> in the class definition file</td></tr><tr><td
bgcolor="#E7E7E7">Default</td><td
bgcolor="#E7E7E7">??? (Undocumented, no examples exist)</td></tr><tr><td
bgcolor="#E7E7E7">Reset</td><td
bgcolor="#E7E7E7">Controls initializing the property using <b>FactoryValue</b> when executing the built-in <i><b>reset</b></i> function</td></tr><tr><td
bgcolor="#E7E7E7">Serialize</td><td
bgcolor="#E7E7E7">Controls whether this object can be serialized</td></tr><tr><td
bgcolor="#E7E7E7">Copy</td><td
bgcolor="#E7E7E7">Controls whether to pass the property&#8217;s current value to a copy</td></tr><tr><td
bgcolor="#E7E7E7">Listener</td><td
bgcolor="#E7E7E7">Controls whether property access events are generated or not</td></tr><tr><td
bgcolor="#E7E7E7">AbortSet</td><td
bgcolor="#E7E7E7">Controls whether property set events are generated when a <i><b>set</b></i> operation will not change the property&#8217;s value</td></tr></table><p>The <b>CaseSensitive</b> meta-property has <b>AccessFlag.Init</b> = <code>'off'</code>. This means that properties added to a class definition file are always case insensitive.</p><p>Another interesting fact is that properties can be abbreviated as long as the abbreviation is unambiguous. Using our <code>simple.object</code> as an example:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">&gt;&gt; a = simple.<span style="">object</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'a'</span><span style="color: #080;">&#41;</span>;
&gt;&gt; a.<span style="">n</span>  <span style="color: #228B22;">% abbreviation of Name</span>
<span style="color: #0000FF;">ans</span> =
a
&nbsp;
&gt;&gt; a.<span style="">v</span>  <span style="color: #228B22;">% abbreviation of Value</span>
<span style="color: #0000FF;">ans</span> =
    <span style="color: #33f;">0.0000</span></pre></div></div><p>It is considered poor programming practice to use either improperly cased, or abbreviated names when writing code. It is difficult to read, debug and maintain. But show me a Matlab programmer who has never abbreviated <b>Position</b> as &#8216;pos&#8217;&#8230;</p><p><i>Note: for completeness&#8217; sake, read yesterday&#8217;s post on <a
target="_blank" rel="nofollow" href="http://blogs.mathworks.com/loren/2011/03/08/common-design-considerations-for-object-properties/">MCOS properties</a> on Loren&#8217;s blog, written by Dave Foti, author of the original UDD code. Dave&#8217;s post describes the fully-documented MCOS mechanism, which is newer than the undocumented UDD mechanism described here. As mentioned earlier, whereas UDD existed (and still exists) in all Matlab 7 releases, MCOS is only available since R2008a. UDD and MCOS co-exist in Matlab since R2008a. MCOS has definite advantages over UDD, but cannot be used on pre-2008 Matlab releases. Different development and deployment requirements may dictate using either UDD or MCOS (or both). Another pre-R2008a alternative is to use Matlab&#8217;s obsolete yet documented <a
target="_blank" rel="nofollow" href="http://www.mathworks.com/help/pdf_doc/matlab/pre-version_7.6_oop.pdf">class system</a>.</i></p><p>In the next installment of this series we will take a look at UDD events and listeners.</p><p><pre> </pre>Related posts:<ol><li><a
href='http://undocumentedmatlab.com/blog/getundoc-get-undocumented-object-properties/' rel='bookmark' title='getundoc &#8211; get undocumented object properties'>getundoc &#8211; get undocumented object properties</a> <small>getundoc is a very simple utility that displays the hidden (undocumented) properties of a specified handle object....</small></li><li><a
href='http://undocumentedmatlab.com/blog/plot-liminclude-properties/' rel='bookmark' title='Plot LimInclude properties'>Plot LimInclude properties</a> <small>The plot objects' XLimInclude, YLimInclude, ZLimInclude, ALimInclude and CLimInclude properties are an important feature, that has both functional and performance implications....</small></li><li><a
href='http://undocumentedmatlab.com/blog/displaying-hidden-handle-properties/' rel='bookmark' title='Displaying hidden handle properties'>Displaying hidden handle properties</a> <small>I present two ways of checking undocumented hidden properties in Matlab Handle Graphics (HG) handles...</small></li><li><a
href='http://undocumentedmatlab.com/blog/borderless-button-used-for-plot-properties/' rel='bookmark' title='Borderless button used for plot properties'>Borderless button used for plot properties</a> <small>A borderless button can be used to add unobtrusive functionality to plot axes...</small></li></ol></p><pre> </pre>]]></content:encoded> <wfw:commentRss>http://undocumentedmatlab.com/blog/udd-properties/feed/</wfw:commentRss> <slash:comments>6</slash:comments> </item> <item><title>Multi-column (grid) legend</title><link>http://undocumentedmatlab.com/blog/multi-column-grid-legend/</link> <comments>http://undocumentedmatlab.com/blog/multi-column-grid-legend/#comments</comments> <pubDate>Mon, 07 Feb 2011 18:00:04 +0000</pubDate> <dc:creator>Yair Altman</dc:creator> <category><![CDATA[Guest bloggers]]></category> <category><![CDATA[Handle graphics]]></category> <category><![CDATA[Hidden property]]></category> <category><![CDATA[Listeners]]></category> <category><![CDATA[Medium risk of breaking in future versions]]></category> <category><![CDATA[Stock Matlab function]]></category> <category><![CDATA[Undocumented feature]]></category> <category><![CDATA[Adrian Cherry]]></category> <category><![CDATA[Listener]]></category> <category><![CDATA[Pure Matlab]]></category> <category><![CDATA[scribe]]></category> <category><![CDATA[Undocumented property]]></category><guid
isPermaLink="false">http://undocumentedmatlab.com/?p=2071</guid> <description><![CDATA[This article explains how to use undocumented axes listeners for implementing multi-column plot legends<pre> </pre>Related posts:<ol><li><a
href='http://undocumentedmatlab.com/blog/legend-semi-documented-feature/' rel='bookmark' title='Legend &#8216;-DynamicLegend&#8217; semi-documented feature'>Legend &#8216;-DynamicLegend&#8217; semi-documented feature</a> <small>The built-in Matlab legend function has a very useful semi-documented feature for automatic dynamic update, which is explained here....</small></li><li><a
href='http://undocumentedmatlab.com/blog/multi-line-tooltips/' rel='bookmark' title='Multi-line tooltips'>Multi-line tooltips</a> <small>Multi-line tooltips are very easy to set up, once you know your way around a few undocumented hiccups....</small></li><li><a
href='http://undocumentedmatlab.com/blog/inactive-control-tooltips-event-chaining/' rel='bookmark' title='Inactive Control Tooltips &amp; Event Chaining'>Inactive Control Tooltips &#038; Event Chaining</a> <small>Inactive Matlab uicontrols cannot normally display their tooltips. This article shows how to do this with a combination of undocumented Matlab and Java hacks....</small></li><li><a
href='http://undocumentedmatlab.com/blog/introduction-to-udd/' rel='bookmark' title='Introduction to UDD'>Introduction to UDD</a> <small>UDD classes underlie many of Matlab's handle-graphics objects and functionality. This article introduces these classes....</small></li></ol><pre> </pre>]]></description> <content:encoded><![CDATA[<p><i>I would like to welcome guest blogger Adrian Cherry. Adrian will describe a very handy utility that shows how basic built-in Matlab functions can be improved and customized by just a bit of fiddling under Matlab&#8217;s hood.</i></p><h3 id="Legend">Legend Plotting</h3><p>Whilst I enjoy using the many time saving features of Matlab, one area where I feel it suffers is the technical plotting and annotation. This tale relates the development of a legend plotting routine, <a
target="_blank" rel="nofollow" href="http://www.mathworks.com/matlabcentral/fileexchange/29248-gridlegend-a-multi-column-format-for-legends">gridLegend</a>, in an effort to improve the presentation.</p><p>In my day job we have a requirement to condense a large quantity of data onto summary charts. However, there is only so much data consolidation possible before you start losing the information required. We often need to plot 40 or 50 lines of test data to visualize trends or outliers, using the legend to identify the number of test hours against each test specimen.</p><p>Using the standard Matlab <i><b>legend</b></i> function resulted in a long legend over twice the size of the associated plot:</p><p><center><div
class="wp-caption aligncenter" style="width: 460px"><img
alt="Standard Matlab legend" src="http://UndocumentedMatlab.com/images/Legend1.png" title="Standard Matlab legend" width="450" height="337" /><p
class="wp-caption-text">Standard Matlab legend</p></div></center></p><p>I wanted some way of generating a more compact legend format.</p><p>Fortunately earlier in the year, an entry on Matlab Central allowing a multi-column legend to be generated was posted, <a
target="_blank" rel="nofollow" href="http://www.mathworks.com/matlabcentral/fileexchange/27389-columnlegend">columnlegend</a>. Although lacking some features, columnlegend gave me a good start on developing what I wanted for a multi column legend, culminating in <a
target="_blank" rel="nofollow" href="http://www.mathworks.com/matlabcentral/fileexchange/29248-gridlegend-a-multi-column-format-for-legends">gridLegend</a>:</p><p><center><div
class="wp-caption aligncenter" style="width: 460px"><img
alt="Multi-column legend" src="http://UndocumentedMatlab.com/images/Legend2.png" title="Multi-column legend" width="450" height="398" /><p
class="wp-caption-text">Multi-column legend</p></div></center></p><h3 id="Undocumented">Delving into the Undocumented Matlab</h3><p>So where is the link with undocumented Matlab?</p><p>As mentioned in the original columnlegend entry, it was relatively simple to redraw the legend as required on the screen. However, as soon as the figure was printed or exported to an image file, internal Matlab workings would redraw the figure, including the legend, thereby undoing my careful legend crafting, squeezing it back into one column (Yuck!):</p><p><center><div
class="wp-caption aligncenter" style="width: 460px"><img
alt="Matlab-reverted multi-column legend" src="http://UndocumentedMatlab.com/images/Legend3.png" title="Matlab-reverted multi-column legend" width="450" height="398" /><p
class="wp-caption-text">Matlab-reverted multi-column legend</p></div></center></p><p>As we wanted to automatically output images files, I had to delve into the hidden areas of Matlab to try to solve this problem.</p><p>My initial thought was to find out where the figure got redrawn for printing or export and override the standard legend call with a call to my new function. I couldn&#8217;t find the obvious culprit, stepping as far as I could through the print function there didn&#8217;t appear to be any call to the legend function.</p><p>In my search for information on how the legend worked I found the undocumented Matlab article about generating <a
target="_blank" href="http://UndocumentedMatlab.com/blog/legend-semi-documented-feature/">dynamic legends</a>. This dynamic-legend post covered details about attaching a listener to a child of the legend axes, in Matlab the legend function creates its own set of axes on the figure to display the legend.</p><p>Armed with the information that legend axes objects could have listeners attached, I considered that these might be the source of redrawing the legend for printing. So with the legend I had generated I took a look at what listeners were attached, using the undocumented hidden axes property <b>ScribeLegendListeners</b>:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">&gt;&gt; legendListener = <span style="color: #0000FF;">get</span><span style="color: #080;">&#40;</span><span style="color: #0000FF;">gca</span>,<span style="color:#A020F0;">'ScribeLegendListeners'</span><span style="color: #080;">&#41;</span>
legendListener = 
        fontname<span style="color: #F0F;">:</span> <span style="color: #080;">&#91;</span>1x1 <span style="color: #0000FF;">handle.<span style="">listener</span></span><span style="color: #080;">&#93;</span>
        fontsize<span style="color: #F0F;">:</span> <span style="color: #080;">&#91;</span>1x1 <span style="color: #0000FF;">handle.<span style="">listener</span></span><span style="color: #080;">&#93;</span>
      fontweight<span style="color: #F0F;">:</span> <span style="color: #080;">&#91;</span>1x1 <span style="color: #0000FF;">handle.<span style="">listener</span></span><span style="color: #080;">&#93;</span>
       fontangle<span style="color: #F0F;">:</span> <span style="color: #080;">&#91;</span>1x1 <span style="color: #0000FF;">handle.<span style="">listener</span></span><span style="color: #080;">&#93;</span>
       linewidth<span style="color: #F0F;">:</span> <span style="color: #080;">&#91;</span>1x1 <span style="color: #0000FF;">handle.<span style="">listener</span></span><span style="color: #080;">&#93;</span>
         deleted<span style="color: #F0F;">:</span> <span style="color: #080;">&#91;</span>1x1 <span style="color: #0000FF;">handle.<span style="">listener</span></span><span style="color: #080;">&#93;</span>
    proxydeleted<span style="color: #F0F;">:</span> <span style="color: #080;">&#91;</span>1x1 <span style="color: #0000FF;">handle.<span style="">listener</span></span><span style="color: #080;">&#93;</span></pre></div></div><p>The font size and line positioning were all being redrawn for printing so this was potentially the source of my problem. However I&#8217;d not looked at a <i><b>handle.listener</b></i> before, so a little further digging was required:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">K&gt;&gt; <span style="color: #0000FF;">get</span><span style="color: #080;">&#40;</span>legendListener.<span style="">fontname</span><span style="color: #080;">&#41;</span>
      SourceObject<span style="color: #F0F;">:</span> <span style="color: #080;">&#91;</span>1x1 schema.<span style="">prop</span><span style="color: #080;">&#93;</span>
         Container<span style="color: #F0F;">:</span> <span style="color: #080;">&#91;</span>1x1 <span style="color: #0000FF;">axes</span><span style="color: #080;">&#93;</span>
         EventType<span style="color: #F0F;">:</span> <span style="color:#A020F0;">'PropertyPostSet'</span>
          Callback<span style="color: #F0F;">:</span> <span style="color: #080;">&#123;</span>2x1 <span style="color: #0000FF;">cell</span><span style="color: #080;">&#125;</span>
    CallbackTarget<span style="color: #F0F;">:</span> <span style="color: #080;">&#91;</span><span style="color: #080;">&#93;</span>
           Enabled<span style="color: #F0F;">:</span> <span style="color:#A020F0;">'on'</span></pre></div></div><p>The option <b>Enabled</b> immediately drew my attention, and so the following lines were added to my gridLegend function to switch off these listeners and apply it back to the legend:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">LL = <span style="color: #0000FF;">get</span><span style="color: #080;">&#40;</span><span style="color: #0000FF;">gca</span>,<span style="color:#A020F0;">'ScribeLegendListeners'</span><span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">set</span><span style="color: #080;">&#40;</span>LL.<span style="">fontname</span>,<span style="color:#A020F0;">'enabled'</span>,<span style="color:#A020F0;">'off'</span><span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">set</span><span style="color: #080;">&#40;</span>LL.<span style="">fontsize</span>,<span style="color:#A020F0;">'enabled'</span>,<span style="color:#A020F0;">'off'</span><span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">set</span><span style="color: #080;">&#40;</span>LL.<span style="">fontweight</span>,<span style="color:#A020F0;">'enabled'</span>,<span style="color:#A020F0;">'off'</span><span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">set</span><span style="color: #080;">&#40;</span>LL.<span style="">fontangle</span>,<span style="color:#A020F0;">'enabled'</span>,<span style="color:#A020F0;">'off'</span><span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">set</span><span style="color: #080;">&#40;</span>LL.<span style="">linewidth</span>,<span style="color:#A020F0;">'enabled'</span>,<span style="color:#A020F0;">'off'</span><span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">set</span><span style="color: #080;">&#40;</span><span style="color: #0000FF;">gca</span>,<span style="color:#A020F0;">'ScribeLegendListeners'</span>,LL<span style="color: #080;">&#41;</span>;</pre></div></div><p>Finally allowing me to output the image files with a multi-column legend:</p><p><center><div
class="wp-caption aligncenter" style="width: 460px"><img
alt="Printed multi-column legend" src="http://UndocumentedMatlab.com/images/Legend4.jpg" title="Printed multi-column legend" width="450" height="363" /><p
class="wp-caption-text">Printed multi-column legend</p></div></center></p><p>So my thanks to the contributors on Matlab Central who enabled me to get started on gridLegend and to Yair for collating the many nuggets of information on Undocumented Matlab which allowed me to complete the function and get it posted on Matlab Central.</p><p><center><div
class="wp-caption aligncenter" style="width: 460px"><img
alt="Multi-column legend in action" src="http://UndocumentedMatlab.com/images/gridLegend.jpg" title="Multi-column legend in action" width="450" height="300" /><p
class="wp-caption-text">Multi-column legend in action</p></div></center></p><p><pre> </pre>Related posts:<ol><li><a
href='http://undocumentedmatlab.com/blog/legend-semi-documented-feature/' rel='bookmark' title='Legend &#8216;-DynamicLegend&#8217; semi-documented feature'>Legend &#8216;-DynamicLegend&#8217; semi-documented feature</a> <small>The built-in Matlab legend function has a very useful semi-documented feature for automatic dynamic update, which is explained here....</small></li><li><a
href='http://undocumentedmatlab.com/blog/multi-line-tooltips/' rel='bookmark' title='Multi-line tooltips'>Multi-line tooltips</a> <small>Multi-line tooltips are very easy to set up, once you know your way around a few undocumented hiccups....</small></li><li><a
href='http://undocumentedmatlab.com/blog/inactive-control-tooltips-event-chaining/' rel='bookmark' title='Inactive Control Tooltips &amp; Event Chaining'>Inactive Control Tooltips &#038; Event Chaining</a> <small>Inactive Matlab uicontrols cannot normally display their tooltips. This article shows how to do this with a combination of undocumented Matlab and Java hacks....</small></li><li><a
href='http://undocumentedmatlab.com/blog/introduction-to-udd/' rel='bookmark' title='Introduction to UDD'>Introduction to UDD</a> <small>UDD classes underlie many of Matlab's handle-graphics objects and functionality. This article introduces these classes....</small></li></ol></p><pre> </pre>]]></content:encoded> <wfw:commentRss>http://undocumentedmatlab.com/blog/multi-column-grid-legend/feed/</wfw:commentRss> <slash:comments>1</slash:comments> </item> </channel> </rss>

<!-- W3 Total Cache: Minify debug info:
Engine:             disk: basic
Theme:              b7666
Template:           tag
-->
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Served from: undocumentedmatlab.com @ 2012-02-04 03:54:56 -->

<!-- W3 Total Cache: Page cache debug info:
Engine:             disk: enhanced
Cache key:          blog/tag/hidden-property/feed/_index.xml_gzip
Caching:            enabled
Status:             not cached
Creation Time:      2.553s
Header info:
X-Pingback:         http://undocumentedmatlab.com/blog/xmlrpc.php
Set-Cookie:         wpgb_visit_last_php-default=1328352894; expires=Sun, 03-Feb-2013 10:54:54 GMT; path=/
Content-Type:       text/xml; charset=UTF-8
Last-Modified:      Sat, 04 Feb 2012 10:54:56 GMT
Vary:               Accept-Encoding, Cookie
Expires:            Sat, 04 Feb 2012 11:54:56 GMT
Pragma:             public
Cache-Control:      public, must-revalidate, proxy-revalidate
Etag:               e55a3df9410578aea319a8aa0639e175
Content-Encoding:   gzip
-->
