<?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; Semi-documented feature</title> <atom:link href="http://undocumentedmatlab.com/blog/category/semi-documented-feature/feed/" rel="self" type="application/rss+xml" /><link>http://undocumentedmatlab.com</link> <description>Charting Matlab's unsupported hidden underbelly</description> <lastBuildDate>Thu, 17 May 2012 12:01:26 +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>Matlab-Java memory leaks, performance</title><link>http://undocumentedmatlab.com/blog/matlab-java-memory-leaks-performance/</link> <comments>http://undocumentedmatlab.com/blog/matlab-java-memory-leaks-performance/#comments</comments> <pubDate>Fri, 20 Jan 2012 00:56:10 +0000</pubDate> <dc:creator>Yair Altman</dc:creator> <category><![CDATA[Java]]></category> <category><![CDATA[Low risk of breaking in future versions]]></category> <category><![CDATA[Memory]]></category> <category><![CDATA[Semi-documented feature]]></category> <category><![CDATA[Stock Matlab function]]></category> <category><![CDATA[Callbacks]]></category> <category><![CDATA[Performance]]></category><guid
isPermaLink="false">http://undocumentedmatlab.com/?p=2665</guid> <description><![CDATA[Internal fields of Java objects may leak memory - this article explains how to avoid this without sacrificing performance.<pre> </pre>Related posts:<ol><li><a
href='http://undocumentedmatlab.com/blog/profiling-matlab-memory-usage/' rel='bookmark' title='Profiling Matlab memory usage'>Profiling Matlab memory usage</a> <small>mtic and mtoc were a couple of undocumented features that enabled users of past Matlab releases to easily profile memory usage. ...</small></li><li><a
href='http://undocumentedmatlab.com/blog/preallocation-performance/' rel='bookmark' title='Preallocation performance'>Preallocation performance</a> <small>Preallocation is a standard Matlab speedup technique. Still, it has several undocumented aspects. ...</small></li><li><a
href='http://undocumentedmatlab.com/blog/performance-scatter-vs-line/' rel='bookmark' title='Performance: scatter vs. line'>Performance: scatter vs. line</a> <small>In many circumstances, the line function can generate visually-identical plots as the scatter function, much faster...</small></li><li><a
href='http://undocumentedmatlab.com/blog/matlab-java-interface-using-static-control/' rel='bookmark' title='Matlab-Java interface using a static control'>Matlab-Java interface using a static control</a> <small>The switchyard function design pattern can be very useful when setting Matlab callbacks to Java GUI controls. This article explains why and how....</small></li></ol><pre> </pre>]]></description> <content:encoded><![CDATA[<p>There are several ways of retrieving information from a Java object into Matlab. On the face of it, all these methods look similar. But it turns out that there are important differences between them in terms of memory leakage and performance.</p><h3 id="Problem">The problem: &#8220;Matlab crashes&#8221; &#8211; now go figure&#8230;</h3><p>A client of one of my Matlab programs recently complained that Matlab crashes after several hours of extensive use of the program. The problem looked like something that is memory related (messages such as Matlab&#8217;s out-of-memory error or Java&#8217;s heap-space error). Apparently this happens even on 64-bit systems having lots of memory, where memory should never be a problem.</p><p>Well, we know that this is only in theory, but in practice Matlab&#8217;s internal memory management has problems that occasionally lead to such crashes. This is one of the reasons, by the way, that recent Matlab releases have added the preference option of increasing the default Java heap space (the previous way to do this was <a
target="_blank" rel="nofollow" href="http://www.mathworks.com/support/solutions/en/data/1-18I2C/">a bit complex</a>). Still, even with a high Java heap space setting and lots of RAM, Matlab crashed after using my program for several hours.</p><p>Not pleasant at all, even a bit of an embarrassment for me. I&#8217;m used to crashing Matlab, but only as a result of my playing around with the internals &#8211; I would hate it to happen to my clients.</p><h3 id="Finding">Finding the leak</h3><p>While we can do little with Matlab&#8217;s internal memory manager, I started searching for the exact location of the memory leak and then to find a way to overcome it. I&#8217;ll save readers the description about the grueling task of finding out exactly where the memory leak occurred in a program that has thousands of lines of code and where events get fired asynchronously on a constant basis. <a
target="_blank" href="http://undocumentedmatlab.com/blog/undocumented-profiler-options/">Matlab Profiler&#8217;s undocumented memory profiling option</a> helped me quite a bit, as well as lots of intuition and trial-and-error. Detecting memory leak is never easy, and I consider myself somewhat lucky this time to have both detected the leak source and a workaround.</p><p>It turned out that the leakage happens in a callback that gets invoked multiple times per second by a Java object (see related articles <a
target="_blank" href="http://undocumentedmatlab.com/blog/uicontrol-callbacks/">here</a> and <a
target="_blank" href="http://undocumentedmatlab.com/blog/matlab-callbacks-for-java-events/">here</a>). Each time the Matlab callback function is invoked, it reads the event information from the supplied Java event-data (the callback&#8217;s second input parameter). Apparently, about 1KB of memory gets leaked whenever this event-data is being read. This may appear a very small leak, but multiply this by some 50-100K callback invocations per hour and you get a leakage of 50-100MB/hour. Not a small leak at all; more of a flood you could say&#8230;</p><h3 id="get">Using <i><b>get</b>()</i></h3><p>The leakage culprit turned out to be the following code snippet:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;"><span style="color: #228B22;">% 160 uSecs per call, with memory leak</span>
eventData  = <span style="color: #0000FF;">get</span><span style="color: #080;">&#40;</span>hEventData,<span style="color: #080;">&#123;</span><span style="color:#A020F0;">'EventName'</span>,<span style="color:#A020F0;">'ParamNames'</span>,<span style="color:#A020F0;">'EventData'</span><span style="color: #080;">&#125;</span><span style="color: #080;">&#41;</span>;
eventName  = eventData<span style="color: #080;">&#123;</span><span style="color: #33f;">1</span><span style="color: #080;">&#125;</span>;
paramNames = eventData<span style="color: #080;">&#123;</span><span style="color: #33f;">2</span><span style="color: #080;">&#125;</span>;
paramData  = eventData<span style="color: #080;">&#123;</span><span style="color: #33f;">3</span><span style="color: #080;">&#125;</span>.<span style="color: #0000FF;">cell</span>;</pre></div></div><p>In this innocent-looking code, <code>hEventData</code> is a Java object that contains the <b>EventName, ParamNames, EventData</b> properties: <b>EventName</b> is a Java <code>String</code>, that is automatically converted by Matlab&#8217;s <i><b>get</b>()</i> function into a Matlab string (<i><b>char</b></i> array); <b>ParamNames</b> is a Java array of <code>String</code>s, that gets automatically converted into a Matlab cell-array of string; and <b>EventData</b> is a Java array of <code>Object</code>s that needs to be converted into a Matlab cell array using the built-in <i><b>cell</b></i> function, as <a
target="_blank" href="http://undocumentedmatlab.com/blog/converting-java-vectors-to-matlab-arrays/">described</a> in one of my recent articles.</p><p>The code is indeed innocent, works really well and is actually extremely fast: each invocation takes of this code segment takes less than 0.2 millisecs. Unfortunately, because of the memory leak I needed to find a better alternative.</p><h3 id="handle">Using <i><b>handle</b>()</i></h3><p>The first idea was to use the built-in <i><b>handle</b>()</i> function, under the assumption that it would solve the memory leak, as <a
target="_blank" rel="nofollow" href="http://mathforum.org/kb/message.jspa?messageID=5950839">reported here</a>. In fact, MathWorks specifically advises to use <i><b>handle</b>()</i> rather than to work with &#8220;naked&#8221; Java objects, when <a
target="_blank" href="http://undocumentedmatlab.com/blog/uicontrol-callbacks/#memory_leak">setting Java object callbacks</a>. The official documentation of the <i><b>set</b></i> function <a
target="_blank" rel="nofollow" href="http://www.mathworks.com/help/techdoc/ref/set.html#f67-433534">says</a>:</p><blockquote><p>Do not use the set function on Java objects as it will cause a memory leak.</p></blockquote><p>It stands to reason then that a similar memory leak happens with <i><b>get</b></i> and that a similar use of <i><b>handle</b></i> would solve this problem:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;"><span style="color: #228B22;">% 300 uSecs per call, with memory leak</span>
s = <span style="color: #0000FF;">get</span><span style="color: #080;">&#40;</span>handle<span style="color: #080;">&#40;</span>hEventData<span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>;
eventName  = s.<span style="">EventName</span>;
paramNames = s.<span style="">ParamNames</span>;
paramData  = <span style="color: #0000FF;">cell</span><span style="color: #080;">&#40;</span>s.<span style="">EventData</span><span style="color: #080;">&#41;</span>;</pre></div></div><p>Unfortunately, this variant, although working correctly, still leaks memory, and also performs almost twice as worse than the original version, taking some 0.3 milliseconds to execute per invocation. Looks like this is a dead end.</p><h3 id="accessor">Using Java accessor methods</h3><p>The next attempt was to use the Java object&#8217;s internal accessor methods for the requested properties. These are <code>public</code> methods of the form <i>getXXX(), isXXX(), setXXX()</i> that enable Matlab to treat XXX as a property by its <i><b>get</b></i> and <i><b>set</b></i> functions. In our case, we need to use the getter methods, as follows:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;"><span style="color: #228B22;">% 380 uSecs per call, no memory leak</span>
eventName  = <span style="color: #0000FF;">char</span><span style="color: #080;">&#40;</span>hEventData.<span style="">getEventName</span><span style="color: #080;">&#41;</span>;
paramNames = <span style="color: #0000FF;">cell</span><span style="color: #080;">&#40;</span>hEventData.<span style="">getParamNames</span><span style="color: #080;">&#41;</span>;
paramData  = <span style="color: #0000FF;">cell</span><span style="color: #080;">&#40;</span>hEventData.<span style="">getEventData</span><span style="color: #080;">&#41;</span>;</pre></div></div><p>Here, the method <i>getEventName()</i> returns a Java <code>String</code>, that we convert into a Matlab string using the <i><b>char</b></i> function. In our previous two variants, the <i><b>get</b></i> function did this conversion for us automatically, but when we use the Java method directly we need to convert the results ourselves. Similarly, when we call <i>getParamNames()</i>, we need to use the <i><b>cell</b></i> function to convert the Java <code>String[]</code> array into a Matlab cell array.</p><p>This version at last doesn&#8217;t leak any memory. Unfortunately, it has an even worse performance: each invocation takes almost 0.4 milliseconds. The difference may seem insignificant. However, recall that this callback gets called dozens of times each second, so the total adds up quickly. It would be nice if there were a faster alternative that does not leak any memory.</p><h3 id="struct">Using <i><b>struct</b>()</i></h3><p>Luckily, I found just such an alternative. At 0.24 millisecs per invocation, it is almost as fast as the leaky best-performance original <i><b>get</b></i> version. Best of all, it leaks no memory, at least none that I could detect.</p><p>The mechanism relies on the little-known fact that public fields of Java objects can be retrieved in Matlab using the built-in <i><b>struct</b></i> function. For example:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">&gt;&gt; fields = <span style="color: #0000FF;">struct</span><span style="color: #080;">&#40;</span>java.<span style="">awt</span>.<span style="color: #0000FF;">Rectangle</span><span style="color: #080;">&#41;</span>
fields = 
             x<span style="color: #F0F;">:</span> <span style="color: #33f;">0</span>
             y<span style="color: #F0F;">:</span> <span style="color: #33f;">0</span>
         width<span style="color: #F0F;">:</span> <span style="color: #33f;">0</span>
        height<span style="color: #F0F;">:</span> <span style="color: #33f;">0</span>
      OUT_LEFT<span style="color: #F0F;">:</span> <span style="color: #33f;">1</span>
       OUT_TOP<span style="color: #F0F;">:</span> <span style="color: #33f;">2</span>
     OUT_RIGHT<span style="color: #F0F;">:</span> <span style="color: #33f;">4</span>
    OUT_BOTTOM<span style="color: #F0F;">:</span> <span style="color: #33f;">8</span>
&nbsp;
&gt;&gt; fields = <span style="color: #0000FF;">struct</span><span style="color: #080;">&#40;</span>java.<span style="">awt</span>.<span style="">Dimension</span><span style="color: #080;">&#41;</span>
fields = 
     width<span style="color: #F0F;">:</span> <span style="color: #33f;">0</span>
    height<span style="color: #F0F;">:</span> <span style="color: #33f;">0</span></pre></div></div><p>Note that this useful mechanism is not mentioned in <a
target="_blank" rel="nofollow" href="http://www.mathworks.com/help/techdoc/matlab_external/f4873.html#f46643">the main documentation page for accessing Java object fields</a>, although it is indeed mentioned in <a
target="_blank" rel="nofollow" href="http://www.mathworks.com/help/techdoc/matlab_external/f6671.html#f61403">another doc-page</a> &#8211; I guess this is a documentation oversight.</p><p>In any case, I converted my Java object to use public (rather than private) fields, so that I could use this <i><b>struct</b></i> mechanism (Matlab can only access public fields). Yes I know that using private fields is a better programming practice and all that (I&#8217;ve programmed OOP for some 15 years&#8230;), but sometimes we need to do ugly things in the interest of performance. The latest version now looks like this:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;"><span style="color: #228B22;">% 240 uSecs per call, no memory leak</span>
s = <span style="color: #0000FF;">struct</span><span style="color: #080;">&#40;</span>hEventData<span style="color: #080;">&#41;</span>;
eventName  = <span style="color: #0000FF;">char</span><span style="color: #080;">&#40;</span>s.<span style="">eventName</span><span style="color: #080;">&#41;</span>;
paramNames = <span style="color: #0000FF;">cell</span><span style="color: #080;">&#40;</span>s.<span style="">paramNames</span><span style="color: #080;">&#41;</span>;
paramData  = <span style="color: #0000FF;">cell</span><span style="color: #080;">&#40;</span>s.<span style="">eventData</span><span style="color: #080;">&#41;</span>;</pre></div></div><p>This solved the memory leakage issue for my client. I felt fortunate that I was not only able to detect Matlab&#8217;s memory leak but also find a working workaround without sacrificing performance or functionality.</p><p>In this particular case, I was lucky to have full control over my Java object, to be able to convert its fields to become public. Unfortunately, we do not always have similar control over the object that we use, because they were coded by a third party.</p><p>By the way, Matlab itself uses this <i><b>struct</b></i> mechanism in its code-base. For example, Matlab timers are implemented using Java objects (<code>com.mathworks.timer.TimerTask</code>). The timer callback in Matlab code converts the Java timer event data into a Matlab struct using the <i><b>struct</b></i> function, in <i>%matlabroot%/toolbox/matlab/iofun/@timer/timercb.m</i>. The users of the timer callbacks then get passed a simple Matlab EventData struct without ever knowing that the original data came from a Java object.</p><p>As an interesting corollary, this same <i><b>struct</b></i> mechanism can be used to detect internal properties of Matlab class objects. For example, in the timers again, we can get the underlying timer&#8217;s Java object as follows (note the highlighted warning, which I find a bit ironic given the context):</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">&gt;&gt; timerObj = timerfind
&nbsp;
   Timer Object<span style="color: #F0F;">:</span> timer-<span style="color: #33f;">1</span>
&nbsp;
   Timer Settings
      ExecutionMode<span style="color: #F0F;">:</span> singleShot
             Period<span style="color: #F0F;">:</span> <span style="color: #33f;">1</span>
           BusyMode<span style="color: #F0F;">:</span> drop
            Running<span style="color: #F0F;">:</span> off
&nbsp;
   Callbacks
           TimerFcn<span style="color: #F0F;">:</span> @myTimerFcn
           ErrorFcn<span style="color: #F0F;">:</span> <span style="color:#A020F0;">''</span>
           StartFcn<span style="color: #F0F;">:</span> <span style="color:#A020F0;">''</span>
            StopFcn<span style="color: #F0F;">:</span> <span style="color:#A020F0;">''</span>
&nbsp;
&gt;&gt; timerFields = <span style="color: #0000FF;">struct</span><span style="color: #080;">&#40;</span>timerObj<span style="color: #080;">&#41;</span>
<span style="display:block;background-color: #ffc;"><span style="color: #0000FF;">Warning</span><span style="color: #F0F;">:</span> Calling <span style="color: #0000FF;">STRUCT</span> on an object prevents the object from hiding its implementation details and should thus be avoided.</span><span style="display:block;background-color: #ffc;"><span style="">Use</span> <span style="color: #0000FF;">DISP</span> or DISPLAY to see the visible public details of an object. <span style="">See</span> <span style="color:#A020F0;">'help struct'</span> <span style="color: #0000FF;">for</span> <span style="color: #0000FF;">more</span> information.</span><span style="display:block;background-color: #ffc;"><span style="color: #080;">&#40;</span><span style="color: #0000FF;">Type</span> &quot;warning off MATLAB<span style="color: #F0F;">:</span>structOnObject&quot; to suppress this <span style="color: #0000FF;">warning</span>.<span style="color: #080;">&#41;</span></span>timerFields = 
         ud<span style="color: #F0F;">:</span> <span style="color: #080;">&#123;</span><span style="color: #080;">&#125;</span>
    jobject<span style="color: #F0F;">:</span> <span style="color: #080;">&#91;</span>1x1 javahandle.<span style="">com</span>.<span style="">mathworks</span>.<span style="">timer</span>.<span style="">TimerTask</span><span style="color: #080;">&#93;</span></pre></div></div><p><pre> </pre>Related posts:<ol><li><a
href='http://undocumentedmatlab.com/blog/profiling-matlab-memory-usage/' rel='bookmark' title='Profiling Matlab memory usage'>Profiling Matlab memory usage</a> <small>mtic and mtoc were a couple of undocumented features that enabled users of past Matlab releases to easily profile memory usage. ...</small></li><li><a
href='http://undocumentedmatlab.com/blog/preallocation-performance/' rel='bookmark' title='Preallocation performance'>Preallocation performance</a> <small>Preallocation is a standard Matlab speedup technique. Still, it has several undocumented aspects. ...</small></li><li><a
href='http://undocumentedmatlab.com/blog/performance-scatter-vs-line/' rel='bookmark' title='Performance: scatter vs. line'>Performance: scatter vs. line</a> <small>In many circumstances, the line function can generate visually-identical plots as the scatter function, much faster...</small></li><li><a
href='http://undocumentedmatlab.com/blog/matlab-java-interface-using-static-control/' rel='bookmark' title='Matlab-Java interface using a static control'>Matlab-Java interface using a static control</a> <small>The switchyard function design pattern can be very useful when setting Matlab callbacks to Java GUI controls. This article explains why and how....</small></li></ol></p><pre> </pre>]]></content:encoded> <wfw:commentRss>http://undocumentedmatlab.com/blog/matlab-java-memory-leaks-performance/feed/</wfw:commentRss> <slash:comments>20</slash:comments> </item> <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/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><li><a
href='http://undocumentedmatlab.com/blog/undocumented-xml-functionality/' rel='bookmark' title='Undocumented XML functionality'>Undocumented XML functionality</a> <small>Matlab's built-in XML-processing functions have several undocumented features that can be used by Java-savvy users...</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/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><li><a
href='http://undocumentedmatlab.com/blog/undocumented-xml-functionality/' rel='bookmark' title='Undocumented XML functionality'>Undocumented XML functionality</a> <small>Matlab's built-in XML-processing functions have several undocumented features that can be used by Java-savvy users...</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>Customizing uitree nodes &#8211; part 1</title><link>http://undocumentedmatlab.com/blog/customizing-uitree-nodes/</link> <comments>http://undocumentedmatlab.com/blog/customizing-uitree-nodes/#comments</comments> <pubDate>Wed, 25 Aug 2010 18:00:20 +0000</pubDate> <dc:creator>Yair Altman</dc:creator> <category><![CDATA[GUI]]></category> <category><![CDATA[Java]]></category> <category><![CDATA[Medium risk of breaking in future versions]]></category> <category><![CDATA[Semi-documented feature]]></category> <category><![CDATA[HTML]]></category> <category><![CDATA[Icons]]></category> <category><![CDATA[Semi-documented function]]></category> <category><![CDATA[uitools]]></category><guid
isPermaLink="false">http://undocumentedmatlab.com/?p=1835</guid> <description><![CDATA[This article describes how to customize specific nodes of Matlab GUI tree controls created using the undocumented uitree function<pre> </pre>Related posts:<ol><li><a
href='http://undocumentedmatlab.com/blog/customizing-uitree-nodes-2/' rel='bookmark' title='Customizing uitree nodes &#8211; part 2'>Customizing uitree nodes &#8211; part 2</a> <small>This article shows how Matlab GUI tree nodes can be customized with checkboxes and similar controls...</small></li><li><a
href='http://undocumentedmatlab.com/blog/customizing-uitree/' rel='bookmark' title='Customizing uitree'>Customizing uitree</a> <small>This article describes how to customize Matlab GUI tree controls created using the undocumented uitree function...</small></li><li><a
href='http://undocumentedmatlab.com/blog/uitree/' rel='bookmark' title='uitree'>uitree</a> <small>This article describes the undocumented Matlab uitree function, which displays data in a GUI tree component...</small></li><li><a
href='http://undocumentedmatlab.com/blog/interesting-uitree-utility/' rel='bookmark' title='An interesting uitree utility'>An interesting uitree utility</a> <small>ExploreStruct is a utility that shows how custom uitrees can be integrated in Matlab GUI...</small></li></ol><pre> </pre>]]></description> <content:encoded><![CDATA[<p>In my previous posts, I introduced the semi-documented <a
target="_blank" href="http://UndocumentedMatlab.com/blog/uitree/"><i><b>uitree</b></i> function</a> that enables displaying data in a hierarchical (tree) control in Matlab GUI, and showed how it can be <a
target="_blank" href="http://UndocumentedMatlab.com/blog/customizing-uitree/">customized</a>. Today, I will continue by describing how specific <i><b>uitree</b></i> nodes can be customized.</p><p>To start the discussion, let&#8217;s re-create last week&#8217;s simple <i><b>uitree</b></i>:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;"><span style="color: #228B22;">% Fruits</span>
fruits = uitreenode<span style="color: #080;">&#40;</span><span style="color:#A020F0;">'v0'</span>, <span style="color:#A020F0;">'Fruits'</span>, <span style="color:#A020F0;">'Fruits'</span>, <span style="color: #080;">&#91;</span><span style="color: #080;">&#93;</span>, <span style="color: #0000FF;">false</span><span style="color: #080;">&#41;</span>;
fruits.<span style="">add</span><span style="color: #080;">&#40;</span>uitreenode<span style="color: #080;">&#40;</span><span style="color:#A020F0;">'v0'</span>, <span style="color:#A020F0;">'Apple'</span>,  <span style="color:#A020F0;">'Apple'</span>,  <span style="color: #080;">&#91;</span><span style="color: #080;">&#93;</span>, <span style="color: #0000FF;">true</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>;
fruits.<span style="">add</span><span style="color: #080;">&#40;</span>uitreenode<span style="color: #080;">&#40;</span><span style="color:#A020F0;">'v0'</span>, <span style="color:#A020F0;">'Pear'</span>,   <span style="color:#A020F0;">'Pear'</span>,   <span style="color: #080;">&#91;</span><span style="color: #080;">&#93;</span>, <span style="color: #0000FF;">true</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>;
fruits.<span style="">add</span><span style="color: #080;">&#40;</span>uitreenode<span style="color: #080;">&#40;</span><span style="color:#A020F0;">'v0'</span>, <span style="color:#A020F0;">'Banana'</span>, <span style="color:#A020F0;">'Banana'</span>, <span style="color: #080;">&#91;</span><span style="color: #080;">&#93;</span>, <span style="color: #0000FF;">true</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>;
fruits.<span style="">add</span><span style="color: #080;">&#40;</span>uitreenode<span style="color: #080;">&#40;</span><span style="color:#A020F0;">'v0'</span>, <span style="color:#A020F0;">'Orange'</span>, <span style="color:#A020F0;">'Orange'</span>, <span style="color: #080;">&#91;</span><span style="color: #080;">&#93;</span>, <span style="color: #0000FF;">true</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>;
&nbsp;
<span style="color: #228B22;">% Vegetables</span>
veggies = uitreenode<span style="color: #080;">&#40;</span><span style="color:#A020F0;">'v0'</span>, <span style="color:#A020F0;">'Veggies'</span>, <span style="color:#A020F0;">'Vegetables'</span>, <span style="color: #080;">&#91;</span><span style="color: #080;">&#93;</span>, <span style="color: #0000FF;">false</span><span style="color: #080;">&#41;</span>;
veggies.<span style="">add</span><span style="color: #080;">&#40;</span>uitreenode<span style="color: #080;">&#40;</span><span style="color:#A020F0;">'v0'</span>, <span style="color:#A020F0;">'Potato'</span>, <span style="color:#A020F0;">'Potato'</span>, <span style="color: #080;">&#91;</span><span style="color: #080;">&#93;</span>, <span style="color: #0000FF;">true</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>;
veggies.<span style="">add</span><span style="color: #080;">&#40;</span>uitreenode<span style="color: #080;">&#40;</span><span style="color:#A020F0;">'v0'</span>, <span style="color:#A020F0;">'Tomato'</span>, <span style="color:#A020F0;">'Tomato'</span>, <span style="color: #080;">&#91;</span><span style="color: #080;">&#93;</span>, <span style="color: #0000FF;">true</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>;
veggies.<span style="">add</span><span style="color: #080;">&#40;</span>uitreenode<span style="color: #080;">&#40;</span><span style="color:#A020F0;">'v0'</span>, <span style="color:#A020F0;">'Carrot'</span>, <span style="color:#A020F0;">'Carrot'</span>, <span style="color: #080;">&#91;</span><span style="color: #080;">&#93;</span>, <span style="color: #0000FF;">true</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>;
&nbsp;
<span style="color: #228B22;">% Root node</span>
root = uitreenode<span style="color: #080;">&#40;</span><span style="color:#A020F0;">'v0'</span>, <span style="color:#A020F0;">'Food'</span>, <span style="color:#A020F0;">'Food'</span>, <span style="color: #080;">&#91;</span><span style="color: #080;">&#93;</span>, <span style="color: #0000FF;">false</span><span style="color: #080;">&#41;</span>;
root.<span style="">add</span><span style="color: #080;">&#40;</span>veggies<span style="color: #080;">&#41;</span>;
root.<span style="">add</span><span style="color: #080;">&#40;</span>fruits<span style="color: #080;">&#41;</span>;
&nbsp;
<span style="color: #228B22;">% Tree</span>
<span style="color: #0000FF;">figure</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'pos'</span>,<span style="color: #080;">&#91;</span><span style="color: #33f;">300</span>,<span style="color: #33f;">300</span>,<span style="color: #33f;">150</span>,<span style="color: #33f;">150</span><span style="color: #080;">&#93;</span><span style="color: #080;">&#41;</span>;
mtree = uitree<span style="color: #080;">&#40;</span><span style="color:#A020F0;">'v0'</span>, <span style="color:#A020F0;">'Root'</span>, root<span style="color: #080;">&#41;</span>;</pre></div></div><p><center><div
class="wp-caption aligncenter" style="width: 360px"><img
alt="User-created tree" src="http://UndocumentedMatlab.com/images/uitree7a.png" title="User-created tree" width="158" height="232" /> &nbsp;&nbsp; <img
alt="User-created tree" src="http://UndocumentedMatlab.com/images/uitree7b.png" title="User-created tree" width="158" height="232" /><p
class="wp-caption-text">User-created tree</p></div></center></p><h3 id="labels">Labels</h3><p>Node labels (descriptions) can be set using their <strong>Name</strong> property (the second <i><b>uitreenode</b></i> data argument). Note that the horizontal space allotted for displaying the node name will not change until the node is collapsed or expanded. So, if the new name requires more than the existing space, it will be displayed as something like &#8220;abc…&#8221;, until the node is expanded or collapsed.</p><p>Node names share the same <a
target="_blank" href="http://undocumentedmatlab.com/blog/html-support-in-matlab-uicomponents/">HTML support feature</a> as all Java Swing labels. Therefore, we can specify font size/face/color, bold, italic, underline, super-/sub-script etc.:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">txt1 = <span style="color:#A020F0;">'&lt;html&gt;&lt;b&gt;&lt;u&gt;&lt;i&gt;abra&lt;/i&gt;&lt;/u&gt;'</span>;
txt2 = <span style="color:#A020F0;">'&lt;font color=&quot;red&quot;&gt;&lt;sup&gt;kadabra&lt;/html&gt;'</span>;
node.<span style="">setName</span><span style="color: #080;">&#40;</span><span style="color: #080;">&#91;</span>txt1,txt2<span style="color: #080;">&#93;</span><span style="color: #080;">&#41;</span>;</pre></div></div><p><center><div
class="wp-caption aligncenter" style="width: 160px"><img
alt="HTML-enriched tree nodes" src="http://UndocumentedMatlab.com/images/uitree2.jpg" title="HTML-enriched tree nodes" width="116" height="50" /><p
class="wp-caption-text">HTML-enriched tree nodes</p></div></center></p><h3 id="icons">Icons</h3><p>Tree-node icons can be specified during node creation, as the third data argument to <i><b>uitreenode</b></i>, which accepts an icon-path (a string):</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">iconPath = <span style="color: #0000FF;">fullfile</span><span style="color: #080;">&#40;</span><span style="color: #0000FF;">matlabroot</span>,<span style="color:#A020F0;">'/toolbox/matlab/icons/greenarrowicon.gif'</span><span style="color: #080;">&#41;</span>;
node = uitreenode<span style="color: #080;">&#40;</span><span style="color:#A020F0;">'v0'</span>,value,name,iconPath,isLeaf<span style="color: #080;">&#41;</span>;</pre></div></div><p>Tree node icons can also be created or modified programmatically in run-time, using Matlab&#8217;s <a
target="_blank" rel="nofollow" href="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/im2java.html">im2java</a> function. Icons can also be loaded from existing files as follows (real-life programs should check and possibly update jImage&#8217;s size to 16 pixels, before setting the node icon, otherwise the icon might get badly cropped; also note the tree-refreshing action):</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">jImage = java.<span style="">awt</span>.<span style="">Toolkit</span>.<span style="">getDefaultToolkit</span>.<span style="">createImage</span><span style="color: #080;">&#40;</span>iconPath<span style="color: #080;">&#41;</span>;
veggies.<span style="">setIcon</span><span style="color: #080;">&#40;</span>jImage<span style="color: #080;">&#41;</span>;
veggies.<span style="">setIcon</span><span style="color: #080;">&#40;</span>im2java<span style="color: #080;">&#40;</span><span style="color: #0000FF;">imread</span><span style="color: #080;">&#40;</span>iconPath<span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>;  <span style="color: #228B22;">% an alternative</span>
&nbsp;
<span style="color: #228B22;">% refresh the veggies node (and all its children)</span>
mtree.<span style="">reloadNode</span><span style="color: #080;">&#40;</span>veggies<span style="color: #080;">&#41;</span>;</pre></div></div><p><center><div
class="wp-caption aligncenter" style="width: 168px"><img
alt="Setting node icon" src="http://UndocumentedMatlab.com/images/uitree7c.png" title="Setting node icon" width="158" height="232" /><p
class="wp-caption-text">Setting node icon</p></div></center></p><h3 id="behavior">Behavior</h3><p>Nodes can be modified from leaf (non-expandable) to parent behavior (=expandable) by setting their <strong>LeafNode</strong> property (a related property is <strong>AllowsChildren</strong>):</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;"><span style="color: #0000FF;">set</span><span style="color: #080;">&#40;</span>node,<span style="color:#A020F0;">'LeafNode'</span>,<span style="color: #0000FF;">false</span><span style="color: #080;">&#41;</span>;  <span style="color: #228B22;">% =expandable</span>
node.<span style="">setLeafNode</span><span style="color: #080;">&#40;</span><span style="color: #33f;">0</span><span style="color: #080;">&#41;</span>;  <span style="color: #228B22;">% an alternative</span></pre></div></div><p>One of the questions I was <a
target="_blank" href="http://undocumentedmatlab.com/blog/uicontrol-callbacks/#comment-388">asked</a> was how to &#8220;disable&#8221; a specific tree node. One way would be to modify the tree&#8217;s <strong>ExpandFcn</strong> callback. Another way is to use a combination of HTML rendering and the node&#8217;s <strong>AllowsChildren</strong> property:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">label = <span style="color: #0000FF;">char</span><span style="color: #080;">&#40;</span>veggies.<span style="">getName</span><span style="color: #080;">&#41;</span>;
veggies.<span style="">setName</span><span style="color: #080;">&#40;</span><span style="color: #080;">&#91;</span><span style="color:#A020F0;">'&lt;html&gt;&lt;font color=&quot;gray&quot;&gt;'</span> label<span style="color: #080;">&#93;</span><span style="color: #080;">&#41;</span>;
veggies.<span style="">setAllowsChildren</span><span style="color: #080;">&#40;</span><span style="color: #0000FF;">false</span><span style="color: #080;">&#41;</span>;
t.<span style="">reloadNode</span><span style="color: #080;">&#40;</span>veggies<span style="color: #080;">&#41;</span>;</pre></div></div><p><center><div
class="wp-caption aligncenter" style="width: 168px"><img
alt="Disabled node" src="http://UndocumentedMatlab.com/images/uitree7d.png" title="Disabled node" width="158" height="232" /><p
class="wp-caption-text">Disabled node</p></div></center></p><p>Another possible behavioral customization is <a
target="_blank" href="http://undocumentedmatlab.com/blog/adding-context-menu-to-uitree/">adding a context-menu to a uitree</a>. We can set node-specific tooltips using similar means.</p><p>Answering a reader&#8217;s <a
target="_blank" href="http://undocumentedmatlab.com/blog/customizing-uitree/#comment-15781">request</a> from last week, tree nodes icons can be used to present checkboxes, radio buttons and other similar node-specific controls. This can actually be done in several ways, that will be explored in next week&#8217;s article.</p><p>There are numerous other possible customizations &#8211; if readers are interested, perhaps I will describe some of them in future articles. If you have any special request, please post a comment <a
href="http://undocumentedmatlab.com/blog/customizing-uitree-nodes/#respond">below</a>.</p><p><pre> </pre>Related posts:<ol><li><a
href='http://undocumentedmatlab.com/blog/customizing-uitree-nodes-2/' rel='bookmark' title='Customizing uitree nodes &#8211; part 2'>Customizing uitree nodes &#8211; part 2</a> <small>This article shows how Matlab GUI tree nodes can be customized with checkboxes and similar controls...</small></li><li><a
href='http://undocumentedmatlab.com/blog/customizing-uitree/' rel='bookmark' title='Customizing uitree'>Customizing uitree</a> <small>This article describes how to customize Matlab GUI tree controls created using the undocumented uitree function...</small></li><li><a
href='http://undocumentedmatlab.com/blog/uitree/' rel='bookmark' title='uitree'>uitree</a> <small>This article describes the undocumented Matlab uitree function, which displays data in a GUI tree component...</small></li><li><a
href='http://undocumentedmatlab.com/blog/interesting-uitree-utility/' rel='bookmark' title='An interesting uitree utility'>An interesting uitree utility</a> <small>ExploreStruct is a utility that shows how custom uitrees can be integrated in Matlab GUI...</small></li></ol></p><pre> </pre>]]></content:encoded> <wfw:commentRss>http://undocumentedmatlab.com/blog/customizing-uitree-nodes/feed/</wfw:commentRss> <slash:comments>4</slash:comments> </item> <item><title>Undocumented XML functionality</title><link>http://undocumentedmatlab.com/blog/undocumented-xml-functionality/</link> <comments>http://undocumentedmatlab.com/blog/undocumented-xml-functionality/#comments</comments> <pubDate>Thu, 19 Nov 2009 01:12:06 +0000</pubDate> <dc:creator>Yair Altman</dc:creator> <category><![CDATA[Java]]></category> <category><![CDATA[Low risk of breaking in future versions]]></category> <category><![CDATA[Semi-documented feature]]></category> <category><![CDATA[Stock Matlab function]]></category><guid
isPermaLink="false">http://undocumentedmatlab.com/?p=751</guid> <description><![CDATA[Matlab's built-in XML-processing functions have several undocumented features that can be used by Java-savvy users<pre> </pre>Related posts:<ol><li><a
href='http://undocumentedmatlab.com/blog/types-of-undocumented-matlab-aspects/' rel='bookmark' title='Types of undocumented Matlab aspects'>Types of undocumented Matlab aspects</a> <small>This article lists the different types of undocumented/unsupported/hidden aspects in Matlab...</small></li><li><a
href='http://undocumentedmatlab.com/blog/more-undocumented-timing-features/' rel='bookmark' title='More undocumented timing features'>More undocumented timing features</a> <small>There are several undocumented ways in Matlab to get CPU and clock data...</small></li><li><a
href='http://undocumentedmatlab.com/blog/tic-toc-undocumented-option/' rel='bookmark' title='tic / toc &#8211; undocumented option'>tic / toc &#8211; undocumented option</a> <small>Matlab's built-in tic/toc functions have an undocumented option enabling multiple nested clockings...</small></li><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></ol><pre> </pre>]]></description> <content:encoded><![CDATA[<p>Matlab&#8217;s built-in XML-processing functions have several undocumented features that can be used by Java-savvy users. We should note that the entire XML-support functionality in Matlab is java-based. I understand that some Matlab users have a general aversion to Java, some even going as far as to disable it using the -nojvm startup option. But if you disable Java, Matlab&#8217;s XML functions will simply not work. Matlab&#8217;s own <a
target="_blank" rel="nofollow" href="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/xmlread.html">documentation</a> points users to Sun&#8217;s official Java website for explanations of how to use the XML functionality (the link in the Matlab docpage is dead &#8211; the correct link should probably be <a
target="_blank" rel="nofollow" href="https://jaxp-sources.dev.java.net/nonav/docs/api/">https://jaxp-sources.dev.java.net/nonav/docs/api/</a>, but Sun keeps changing its website so this link could also be dead soon&#8230;).</p><p>Using the full Java XML parsing (<a
target="_blank" rel="nofollow" href="https://jaxp.dev.java.net/">JAXP</a>) functionality is admittedly quite intimidating for the uninitiated, but extremely powerful once you understand how all the pieces fit together. Over the years, several interesting utilities were submitted to the Matlab File Exchange that simplify this intimidating post-processing. See for example <a
target="_blank" rel="nofollow" href="http://www.mathworks.com/matlabcentral/fileexchange/3074-xml-parsing-tools">XML parsing tools</a>, the extremely popular <a
target="_blank" rel="nofollow" href="http://www.mathworks.com/matlabcentral/fileexchange/4278-xml-toolbox">XML Toolbox</a> and <a
target="_blank" rel="nofollow" href="http://www.mathworks.com/matlabcentral/fileexchange/12907-xmliotools">xml_io_tools</a>, the recent <a
target="_blank" rel="nofollow" href="http://www.mathworks.com/matlabcentral/fileexchange/18253-xml-data-import">XML data import</a> and perhaps a dozen other utilities.</p><p>Each of Matlab&#8217;s main built-in XML-processing functions, <b><i>xmlread</i></b>, <b><i>xmlwrite</i></b> and <b><i>xslt</i></b> has an internal set of undocumented and unsupported functionalities, which builds on their internal Java implementation. As far as I could tell, these unsupported functionalities were supported at least as early as Matlab 7.2 (R2006a), and possibly even on earlier releases. For the benefit of the Java and/or JAXP -speakers out there (it will probably not help any others), I list Matlab&#8217;s internal description of these unsupported functionalities, annotated with API hyperlinks. These description (sans the links) can be seen by simply editing the m file, as in (the R2008a variant is described below):</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;"><span style="color: #0000FF;">edit</span> xmlread</pre></div></div><h3><i>xmlread</i></h3><p></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>parseResult,p<span style="color: #080;">&#93;</span> = xmlread<span style="color: #080;">&#40;</span>fileName,<span style="color: #0000FF;">varargin</span><span style="color: #080;">&#41;</span></pre></div></div><ul><li>FILENAME can also be an <a
target="_blank" rel="nofollow" href="https://jaxp-sources.dev.java.net/nonav/docs/api/org/xml/sax/InputSource.html">InputSource</a>, <a
target="_blank" rel="nofollow" href="http://java.sun.com/javase/6/docs/api/java/io/File.html">File</a>, or <a
target="_blank" rel="nofollow" href="http://java.sun.com/javase/6/docs/api/java/io/InputStream.html">InputStream</a> object</li><li>DOMNODE = XMLREAD(FILENAME,&#8230;,P,&#8230;) where P is a <a
target="_blank" rel="nofollow" href="http://java.sun.com/javase/6/docs/api/javax/xml/parsers/DocumentBuilder.html">DocumentBuilder</a> object</li><li>DOMNODE = XMLREAD(FILENAME,&#8230;,&#8217;-validating&#8217;,&#8230;) will create a validating parser if one was not provided.</li><li>DOMNODE = XMLREAD(FILENAME,&#8230;,ER,&#8230;) where ER is an <a
target="_blank" rel="nofollow" href="https://jaxp-sources.dev.java.net/nonav/docs/api/org/xml/sax/EntityResolver.html">EntityResolver</a> will set the EntityResolver before parsing</li><li>DOMNODE = XMLREAD(FILENAME,&#8230;,EH,&#8230;) where EH is an <a
target="_blank" rel="nofollow" href="https://jaxp-sources.dev.java.net/nonav/docs/api/org/xml/sax/ErrorHandler.html">ErrorHandler</a> will set the ErrorHandler before parsing</li><li>[DOMNODE,P] = XMLREAD(FILENAME,&#8230;) will return a parser suitable for passing back to XMLREAD for future parses.</li></ul><h3><i>xmlwrite</i></h3><p></p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;"><span style="color: #0000FF;">function</span> xmlwrite<span style="color: #080;">&#40;</span>FILENAME,DOMNODE<span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">function</span> str = xmlwrite<span style="color: #080;">&#40;</span>DOMNODE<span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">function</span> str = xmlwrite<span style="color: #080;">&#40;</span>SOURCE<span style="color: #080;">&#41;</span>;</pre></div></div><ul><li>FILENAME can also be a <a
target="_blank" rel="nofollow" href="http://en.wikipedia.org/wiki/Uniform_Resource_Name">URN</a>, <a
target="_blank" rel="nofollow" href="http://java.sun.com/javase/6/docs/api/java/io/OutputStream.html">java.io.OutputStream</a> or <a
target="_blank" rel="nofollow" href="http://java.sun.com/javase/6/docs/api/java/io/Writer.html">java.io.Writer</a> object</li><li>SOURCE can also be a SAX <a
target="_blank" rel="nofollow" href="https://jaxp-sources.dev.java.net/nonav/docs/api/org/xml/sax/InputSource.html">InputSource</a>, <a
target="_blank" rel="nofollow" href="https://jaxp-sources.dev.java.net/nonav/docs/api/javax/xml/transform/Source.html">JAXP Source</a>, <a
target="_blank" rel="nofollow" href="http://java.sun.com/javase/6/docs/api/java/io/InputStream.html">InputStream</a>, or <a
target="_blank" rel="nofollow" href="http://java.sun.com/javase/6/docs/api/java/io/Reader.html">Reader</a> object</li></ul><h3><i>xslt</i></h3><p></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>xResultURI,xProcessor<span style="color: #080;">&#93;</span> = xslt<span style="color: #080;">&#40;</span>SOURCE,STYLE,DEST,<span style="color: #0000FF;">varargin</span><span style="color: #080;">&#41;</span></pre></div></div><ul><li>SOURCE can also be a <a
target="_blank" rel="nofollow" href="http://xerces.apache.org/xerces2-j/javadocs/xni/org/apache/xerces/xni/parser/XMLInputSource.html">XSLTInputSource</a></li><li>STYLE can also be a StylesheetRoot or XSLTInputSource</li><li>DEST can also be an XSLTResultTarget.  Note that RESULT may be empty in this case since it may not be possible to determine a URL. If STYLE is absent or empty, the function uses the stylesheet named in the xml-stylesheet processing instruction in the SOURCE XML file.  (This does not always work)</li><li>There is also an entirely undocumented feature: passing a &#8216;-tostring&#8217; input argument transforms the inputs into a displayed text segment, rather than into a displayed URI; the transformed text is returned in the xResultURI output argument.</li></ul><p>Note: internal comments within the Matlab code seem to indicate that XSLT is <a
target="_blank" rel="nofollow" href="http://saxon.sourceforge.net/">SAXON</a>-based, so interested users might use SAXON&#8217;s documentation for accessing additional XSLT-related features/capabilities.</p><p><pre> </pre>Related posts:<ol><li><a
href='http://undocumentedmatlab.com/blog/types-of-undocumented-matlab-aspects/' rel='bookmark' title='Types of undocumented Matlab aspects'>Types of undocumented Matlab aspects</a> <small>This article lists the different types of undocumented/unsupported/hidden aspects in Matlab...</small></li><li><a
href='http://undocumentedmatlab.com/blog/more-undocumented-timing-features/' rel='bookmark' title='More undocumented timing features'>More undocumented timing features</a> <small>There are several undocumented ways in Matlab to get CPU and clock data...</small></li><li><a
href='http://undocumentedmatlab.com/blog/tic-toc-undocumented-option/' rel='bookmark' title='tic / toc &#8211; undocumented option'>tic / toc &#8211; undocumented option</a> <small>Matlab's built-in tic/toc functions have an undocumented option enabling multiple nested clockings...</small></li><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></ol></p><pre> </pre>]]></content:encoded> <wfw:commentRss>http://undocumentedmatlab.com/blog/undocumented-xml-functionality/feed/</wfw:commentRss> <slash:comments>6</slash:comments> </item> <item><title>Legend &#8216;-DynamicLegend&#8217; semi-documented feature</title><link>http://undocumentedmatlab.com/blog/legend-semi-documented-feature/</link> <comments>http://undocumentedmatlab.com/blog/legend-semi-documented-feature/#comments</comments> <pubDate>Thu, 04 Jun 2009 23:00:22 +0000</pubDate> <dc:creator>Yair Altman</dc:creator> <category><![CDATA[GUI]]></category> <category><![CDATA[Listeners]]></category> <category><![CDATA[Medium risk of breaking in future versions]]></category> <category><![CDATA[Semi-documented feature]]></category> <category><![CDATA[Stock Matlab function]]></category> <category><![CDATA[Listener]]></category> <category><![CDATA[Pure Matlab]]></category> <category><![CDATA[scribe]]></category><guid
isPermaLink="false">http://undocumentedmatlab.com/?p=357</guid> <description><![CDATA[The built-in Matlab legend function has a very useful semi-documented feature for automatic dynamic update, which is explained here.<pre> </pre>Related posts:<ol><li><a
href='http://undocumentedmatlab.com/blog/multi-column-grid-legend/' rel='bookmark' title='Multi-column (grid) legend'>Multi-column (grid) legend</a> <small>This article explains how to use undocumented axes listeners for implementing multi-column plot legends...</small></li><li><a
href='http://undocumentedmatlab.com/blog/undocumented-feature-function/' rel='bookmark' title='Undocumented feature() function'>Undocumented feature() function</a> <small>Matlab's undocumented feature function enables access to some internal experimental features...</small></li><li><a
href='http://undocumentedmatlab.com/blog/plot-performance/' rel='bookmark' title='Plot performance'>Plot performance</a> <small>Undocumented inner plot mechanisms can be used to significantly improved plotting performance...</small></li><li><a
href='http://undocumentedmatlab.com/blog/context-sensitive-help/' rel='bookmark' title='Context-Sensitive Help'>Context-Sensitive Help</a> <small>Matlab has a hidden/unsupported built-in mechanism for easy implementation of context-sensitive help...</small></li></ol><pre> </pre>]]></description> <content:encoded><![CDATA[<p>In one of my projects, I had to build a GUI in which users could interactively add and remove plot lines from an axes. The problem was that the legend needed to be kept in constant sync with the currently-displayed plot lines. This can of course be done programmatically, but a much simpler solution was to use <em><strong>legend</strong></em>&#8216;s semi-documented &#8216;-DynamicLegend&#8217; feature. Here&#8217;s a simple example:</p><blockquote><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">x=<span style="color: #33f;">0</span><span style="color: #F0F;">:</span>.01<span style="color: #F0F;">:</span><span style="color: #33f;">10</span>;
<span style="color: #0000FF;">plot</span><span style="color: #080;">&#40;</span>x, <span style="color: #0000FF;">sin</span><span style="color: #080;">&#40;</span>x<span style="color: #080;">&#41;</span>, <span style="color:#A020F0;">'DisplayName'</span>,<span style="color:#A020F0;">'sin'</span><span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">legend</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'-DynamicLegend'</span><span style="color: #080;">&#41;</span>;
&nbsp;
<span style="color: #0000FF;">hold</span> <span style="color: #0000FF;">all</span>;   <span style="color: #228B22;">% add new plot lines on top of previous ones</span>
<span style="color: #0000FF;">plot</span><span style="color: #080;">&#40;</span>x, <span style="color: #0000FF;">cos</span><span style="color: #080;">&#40;</span>x<span style="color: #080;">&#41;</span>, <span style="color:#A020F0;">'DisplayName'</span>,<span style="color:#A020F0;">'cos'</span><span style="color: #080;">&#41;</span>;</pre></div></div></blockquote><p>We can see how the dynamic legend automatically keeps in sync with its associated axes contents when plot lines are added/removed, even down to the zoom-box lines&#8230; The legend automatically uses the plot lines &#8216;DisplayName&#8217; property where available, or a standard &#8216;line#&#8217; nametag where not available:<br
/><center><br
/><div
class="wp-caption aligncenter" style="width: 310px"><img
alt="Dynamic legend" src="http://undocumentedmatlab.com/images/legend_animated.gif" title="Dynamic legend" width="300" height="308" /><p
class="wp-caption-text">Dynamic legend</p></div></center></p><p>DynamicLegend works by attaching a listener to the axes child addition/deletion callback (actually, it works on the scribe object, which is a large topic for several future posts). It is sometimes necessary to selectively disable the dynamic behavior. For example, in my GUI I needed to plot several event lines which looked alike, and so I only wanted the first line to be added to the legend. To temporarily disable the DynamicLegend listener, do the following:</p><blockquote><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;"><span style="color: #228B22;">% Try to disable this axes's legend plot-addition listener</span>
legendAxListener = <span style="color: #080;">&#91;</span><span style="color: #080;">&#93;</span>;
<span style="color: #0000FF;">try</span>
   legendListeners = <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>;
   legendAxListener = legendListeners.<span style="">childadded</span>;
   <span style="color: #0000FF;">set</span><span style="color: #080;">&#40;</span>legendAxListener,<span style="color:#A020F0;">'Enable'</span>,<span style="color:#A020F0;">'off'</span><span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">catch</span>
   <span style="color: #228B22;">% never mind...</span>
<span style="color: #0000FF;">end</span>
&nbsp;
<span style="color: #228B22;">% Update the axes - the legend will not be updated</span>
<span style="color: #F0F;">...</span>
&nbsp;
<span style="color: #228B22;">% Re-enable the dynamic legend listener</span>
<span style="color: #0000FF;">set</span><span style="color: #080;">&#40;</span>legendAxListener,<span style="color:#A020F0;">'Enable'</span>,<span style="color:#A020F0;">'on'</span><span style="color: #080;">&#41;</span>;</pre></div></div></blockquote><p>Unfortunately, this otherwise-useful DynamicLegend feature throws errors when zooming-in on <em><strong>bar</strong></em> or <em><strong>stairs</strong></em> graphs. This can be replicated by:</p><blockquote><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;"><span style="color: #0000FF;">figure</span>;
<span style="color: #0000FF;">bar</span><span style="color: #080;">&#40;</span><span style="color: #0000FF;">magic</span><span style="color: #080;">&#40;</span><span style="color: #33f;">4</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>;  <span style="color: #228B22;">%or: stairs(magic(3),magic(3));</span>
<span style="color: #0000FF;">legend</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'-DynamicLegend'</span><span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">zoom</span> on;
<span style="color: #228B22;">% Now zoom-in using the mouse to get the errors on the Command Window</span></pre></div></div></blockquote><p>The fix: modify %MATLABROOT%\toolbox\matlab\scribe\@scribe\@legend\init.m line #528 as follows:</p><blockquote><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;"><span style="color: #228B22;">%old:</span>
str = <span style="color: #080;">&#91;</span>str<span style="color: #080;">&#40;</span><span style="color: #33f;">1</span><span style="color: #F0F;">:</span>insertindex-<span style="color: #33f;">1</span><span style="color: #080;">&#41;</span>;<span style="color: #080;">&#123;</span>newstr<span style="color: #080;">&#125;</span>;str<span style="color: #080;">&#40;</span>insertindex<span style="color: #F0F;">:</span><span style="color: #0000FF;">length</span><span style="color: #080;">&#40;</span>str<span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#93;</span>;
&nbsp;
<span style="color: #228B22;">%new:</span>
<span style="color: #0000FF;">if</span> <span style="color: #0000FF;">size</span><span style="color: #080;">&#40;</span>str,<span style="color: #33f;">2</span><span style="color: #080;">&#41;</span>&gt;size<span style="color: #080;">&#40;</span>str,<span style="color: #33f;">1</span><span style="color: #080;">&#41;</span>
    str=<span style="color: #080;">&#91;</span>str<span style="color: #080;">&#40;</span><span style="color: #33f;">1</span><span style="color: #F0F;">:</span>insertindex-<span style="color: #33f;">1</span><span style="color: #080;">&#41;</span>,<span style="color: #080;">&#123;</span>newstr<span style="color: #080;">&#125;</span>,str<span style="color: #080;">&#40;</span>insertindex<span style="color: #F0F;">:</span><span style="color: #0000FF;">length</span><span style="color: #080;">&#40;</span>str<span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#93;</span>;
<span style="color: #0000FF;">else</span>
    str=<span style="color: #080;">&#91;</span>str<span style="color: #080;">&#40;</span><span style="color: #33f;">1</span><span style="color: #F0F;">:</span>insertindex-<span style="color: #33f;">1</span><span style="color: #080;">&#41;</span>;<span style="color: #080;">&#123;</span>newstr<span style="color: #080;">&#125;</span>;str<span style="color: #080;">&#40;</span>insertindex<span style="color: #F0F;">:</span><span style="color: #0000FF;">length</span><span style="color: #080;">&#40;</span>str<span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#93;</span>;
<span style="color: #0000FF;">end</span></pre></div></div></blockquote><p>The origin of the bug is that <em><strong>bar</strong></em> and <em><strong>stairs</strong></em> generate <em><strong>hggroup</strong></em> plot-children, which saves the legend strings column-wise rather than the expected row-wise. My fix solves this, but I do not presume this solves all possible problems in all scenarios (please report if you find anything else).</p><h3 id="Semi-documented">Semi-documented</h3><p>The DynamicLegend feature is semi-documented. This means that the feature is explained in a comment within the function (which can be seen via the <strong><em>edit</em></strong>(<span
style="color: rgb(160, 32, 240);">&#8216;legend&#8217;</span>) command), that is nonetheless not part of the official help or doc sections. It is an unsupported feature originally intended only for internal Matlab use (which of course doesn&#8217;t mean we can&#8217;t use it). This feature has existed many releases back (Matlab 7.1 for sure, perhaps earlier), so while it may be discontinued in some future Matlab release, it did have a very long life span&#8230; The down side is that it is not supported: I reported the bar/stairs issue back in mid-2007 and so far this has not been addressed (perhaps it will never be). Even my reported workaround in January this year went unanswered (no hard feelings&#8230;).</p><p>DynamicLegend is a good example of a useful semi-documented feature. Some other examples, which I may cover in future posts, include <strong><em>text</em></strong>(&#8230;,<span
style="color: rgb(160, 32, 240);">&#8216;sc&#8217;</span>), <strong><em>drawnow</em></strong>(<span
style="color: rgb(160, 32, 240);">&#8216;discard&#8217;</span>), several options in <strong><em>pan</em></strong> and <strong><em>datacursormode</em></strong> etc. etc.</p><p>There are also entire semi-documented functions: many of the uitools (e.g., <strong><em>uitree</em></strong>, <strong><em>uiundo</em></strong>), as well as <strong><em>hgfeval</em></strong> and others.</p><p>Have you discovered any useful semi-documented feature or function? If so, then please share your finding in the comments section below.</p><p><pre> </pre>Related posts:<ol><li><a
href='http://undocumentedmatlab.com/blog/multi-column-grid-legend/' rel='bookmark' title='Multi-column (grid) legend'>Multi-column (grid) legend</a> <small>This article explains how to use undocumented axes listeners for implementing multi-column plot legends...</small></li><li><a
href='http://undocumentedmatlab.com/blog/undocumented-feature-function/' rel='bookmark' title='Undocumented feature() function'>Undocumented feature() function</a> <small>Matlab's undocumented feature function enables access to some internal experimental features...</small></li><li><a
href='http://undocumentedmatlab.com/blog/plot-performance/' rel='bookmark' title='Plot performance'>Plot performance</a> <small>Undocumented inner plot mechanisms can be used to significantly improved plotting performance...</small></li><li><a
href='http://undocumentedmatlab.com/blog/context-sensitive-help/' rel='bookmark' title='Context-Sensitive Help'>Context-Sensitive Help</a> <small>Matlab has a hidden/unsupported built-in mechanism for easy implementation of context-sensitive help...</small></li></ol></p><pre> </pre>]]></content:encoded> <wfw:commentRss>http://undocumentedmatlab.com/blog/legend-semi-documented-feature/feed/</wfw:commentRss> <slash:comments>14</slash:comments> </item> </channel> </rss>

<!-- W3 Total Cache: Minify debug info:
Engine:             disk: basic
Theme:              b7666
Template:           category
-->
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Served from: undocumentedmatlab.com @ 2012-05-18 21:49:08 -->

<!-- W3 Total Cache: Page cache debug info:
Engine:             disk: enhanced
Cache key:          blog/category/semi-documented-feature/feed/_index.xml_gzip
Caching:            enabled
Status:             not cached
Creation Time:      1.199s
Header info:
X-Pingback:         http://undocumentedmatlab.com/blog/xmlrpc.php
Set-Cookie:         wpgb_visit_last_php-default=1337402947; expires=Sun, 19-May-2013 04:49:07 GMT; path=/
Content-Type:       text/xml; charset=UTF-8
Last-Modified:      Sat, 19 May 2012 04:49:08 GMT
Vary:               Accept-Encoding, Cookie
Expires:            Sat, 19 May 2012 05:49:08 GMT
Pragma:             public
Cache-Control:      public, must-revalidate, proxy-revalidate
Etag:               f81e88f7ddf5c543a88cffc4136c4be1
Content-Encoding:   gzip
-->
