<?xml version="1.0" encoding="UTF-8"?><rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
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/"
> <channel><title>Comments on: cprintf &#8211; display formatted color text in the Command Window</title> <atom:link href="http://undocumentedmatlab.com/blog/cprintf-display-formatted-color-text-in-command-window/feed/" rel="self" type="application/rss+xml" /><link>http://undocumentedmatlab.com/blog/cprintf-display-formatted-color-text-in-command-window/</link> <description>Charting Matlab's unsupported hidden underbelly</description> <lastBuildDate>Thu, 09 Feb 2012 09:23:08 +0000</lastBuildDate> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.1.1</generator> <item><title>By: Yair Altman</title><link>http://undocumentedmatlab.com/blog/cprintf-display-formatted-color-text-in-command-window/#comment-63459</link> <dc:creator>Yair Altman</dc:creator> <pubDate>Mon, 28 Nov 2011 14:26:16 +0000</pubDate> <guid
isPermaLink="false">http://undocumentedmatlab.com/?p=274#comment-63459</guid> <description>For all the people who have noted about cprintf&#039;s issues with R2011b, the new version that was just uploaded fixes those problems, as well as the issue of the space (on R2011b only)</description> <content:encoded><![CDATA[<p>For all the people who have noted about cprintf&#8217;s issues with R2011b, the new version that was just uploaded fixes those problems, as well as the issue of the space (on R2011b only)</p> ]]></content:encoded> </item> <item><title>By: Helge</title><link>http://undocumentedmatlab.com/blog/cprintf-display-formatted-color-text-in-command-window/#comment-56284</link> <dc:creator>Helge</dc:creator> <pubDate>Thu, 08 Sep 2011 16:22:17 +0000</pubDate> <guid
isPermaLink="false">http://undocumentedmatlab.com/?p=274#comment-56284</guid> <description>@Yair, \r is nice to clear an entire line back to its beginning, but the content is nevertheless displayed on a new line, as with \n. I tried the following to check this (with as well as without extra \b on either side of \r):
&lt;pre lang=&quot;matlab&quot;&gt;
&gt;&gt; fprintf([&#039;off\n&#039;]); for n=1:10, pause(0.5); fprintf([&#039;\b\ron \n&#039;]); pause(0.5); fprintf([&#039;\b\roff\n&#039;]); end
on
off
on
off
...
&lt;/pre&gt;The multiple \b solution (+repmat, if this makes things simpler), in contrast, overwrites the last line with either on or off, so that the progress message is updated in-place, rather than adding a new line of output to the CW. In other words: the \b hack avoids that previous messages scroll out on top of the CW. Nevertheless, thx for \r, I was not yet aware of that.</description> <content:encoded><![CDATA[<p>@Yair, \r is nice to clear an entire line back to its beginning, but the content is nevertheless displayed on a new line, as with \n. I tried the following to check this (with as well as without extra \b on either side of \r):</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">&gt;&gt; <span style="color: #0000FF;">fprintf</span><span style="color: #080;">&#40;</span><span style="color: #080;">&#91;</span><span style="color:#A020F0;">'off\n'</span><span style="color: #080;">&#93;</span><span style="color: #080;">&#41;</span>; <span style="color: #0000FF;">for</span> n=<span style="color: #33f;">1</span><span style="color: #F0F;">:</span><span style="color: #33f;">10</span>, <span style="color: #0000FF;">pause</span><span style="color: #080;">&#40;</span><span style="color: #33f;">0.5</span><span style="color: #080;">&#41;</span>; <span style="color: #0000FF;">fprintf</span><span style="color: #080;">&#40;</span><span style="color: #080;">&#91;</span><span style="color:#A020F0;">'\b\ron \n'</span><span style="color: #080;">&#93;</span><span style="color: #080;">&#41;</span>; <span style="color: #0000FF;">pause</span><span style="color: #080;">&#40;</span><span style="color: #33f;">0.5</span><span style="color: #080;">&#41;</span>; <span style="color: #0000FF;">fprintf</span><span style="color: #080;">&#40;</span><span style="color: #080;">&#91;</span><span style="color:#A020F0;">'\b\roff\n'</span><span style="color: #080;">&#93;</span><span style="color: #080;">&#41;</span>; <span style="color: #0000FF;">end</span>
on
off
on
off
<span style="color: #F0F;">...</span></pre></div></div><p>The multiple \b solution (+repmat, if this makes things simpler), in contrast, overwrites the last line with either on or off, so that the progress message is updated in-place, rather than adding a new line of output to the CW. In other words: the \b hack avoids that previous messages scroll out on top of the CW. Nevertheless, thx for \r, I was not yet aware of that.</p> ]]></content:encoded> </item> <item><title>By: Yair Altman</title><link>http://undocumentedmatlab.com/blog/cprintf-display-formatted-color-text-in-command-window/#comment-56189</link> <dc:creator>Yair Altman</dc:creator> <pubDate>Wed, 07 Sep 2011 19:18:38 +0000</pubDate> <guid
isPermaLink="false">http://undocumentedmatlab.com/?p=274#comment-56189</guid> <description>@Helge - you could try to use &#039;\r&#039; instead of multiple &#039;\b&#039;</description> <content:encoded><![CDATA[<p>@Helge &#8211; you could try to use &#8216;\r&#8217; instead of multiple &#8216;\b&#8217;</p> ]]></content:encoded> </item> <item><title>By: Helge</title><link>http://undocumentedmatlab.com/blog/cprintf-display-formatted-color-text-in-command-window/#comment-56187</link> <dc:creator>Helge</dc:creator> <pubDate>Wed, 07 Sep 2011 19:10:35 +0000</pubDate> <guid
isPermaLink="false">http://undocumentedmatlab.com/?p=274#comment-56187</guid> <description>To whom it may concern: here is another useful hack (not really undocumented but one of the most underrated/unknown), that I have been using to replace the last few characters at the end of progressbar-like message strings inside loops.step 1:
&lt;pre lang=&quot;matlab&quot;&gt;
&gt;&gt; fprintf(&#039;progress: ..... 50%%\n&#039;);
progress: ..... 50%
&lt;/pre&gt;step 2:
&lt;pre lang=&quot;matlab&quot;&gt;
&gt;&gt; fprintf(&#039;progress: ..... 50%%\n&#039;); fprintf([&#039;\b\b\b\b\b. 60%%\n&#039;]);
progress: ...... 60%
&lt;/pre&gt;similarly, step 3 (blinking text):
&lt;pre lang=&quot;matlab&quot;&gt;
&gt;&gt; fprintf([&#039;off\n&#039;]); for n=1:10, pause(0.5); fprintf([&#039;\b\b\b\bon \n&#039;]); pause(0.5); fprintf([&#039;\b\b\b\boff\n&#039;]); end
on   (toggles on/off each second)
&lt;/pre&gt;step 4 (in a loop):
&lt;pre lang=&quot;matlab&quot;&gt;
&gt;&gt; fprintf(&#039;progress:  00%%\n&#039;); for n=1:10, pause(1); fprintf([&#039;\b\b\b\b\b. %d%%\n&#039;],10*n); end
progress: .....well, this text will change once a second
&lt;/pre&gt;The pause command in the example represents a sequence of time-consuming operations. Note that we don&#039;t need any timer objects, GUI callbacks, class events, Java, com.mathworks.etc here. Just raw C format specifications, doing their dirty deeds since Matlab 5 (or earlier). The general strategy should also work with cprintf, so thanks Yair we can finally see those progressbars grow in any color.</description> <content:encoded><![CDATA[<p>To whom it may concern: here is another useful hack (not really undocumented but one of the most underrated/unknown), that I have been using to replace the last few characters at the end of progressbar-like message strings inside loops.</p><p>step 1:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">&gt;&gt; <span style="color: #0000FF;">fprintf</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'progress: ..... 50%%\n'</span><span style="color: #080;">&#41;</span>; 
progress<span style="color: #F0F;">:</span> <span style="color: #F0F;">...</span>.. <span style="color: #33f;">50</span><span style="color: #228B22;">%</span></pre></div></div><p>step 2:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">&gt;&gt; <span style="color: #0000FF;">fprintf</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'progress: ..... 50%%\n'</span><span style="color: #080;">&#41;</span>; <span style="color: #0000FF;">fprintf</span><span style="color: #080;">&#40;</span><span style="color: #080;">&#91;</span><span style="color:#A020F0;">'\b\b\b\b\b. 60%%\n'</span><span style="color: #080;">&#93;</span><span style="color: #080;">&#41;</span>;
progress<span style="color: #F0F;">:</span> <span style="color: #F0F;">......</span> <span style="color: #33f;">60</span><span style="color: #228B22;">%</span></pre></div></div><p>similarly, step 3 (blinking text):</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">&gt;&gt; <span style="color: #0000FF;">fprintf</span><span style="color: #080;">&#40;</span><span style="color: #080;">&#91;</span><span style="color:#A020F0;">'off\n'</span><span style="color: #080;">&#93;</span><span style="color: #080;">&#41;</span>; <span style="color: #0000FF;">for</span> n=<span style="color: #33f;">1</span><span style="color: #F0F;">:</span><span style="color: #33f;">10</span>, <span style="color: #0000FF;">pause</span><span style="color: #080;">&#40;</span><span style="color: #33f;">0.5</span><span style="color: #080;">&#41;</span>; <span style="color: #0000FF;">fprintf</span><span style="color: #080;">&#40;</span><span style="color: #080;">&#91;</span><span style="color:#A020F0;">'\b\b\b\bon \n'</span><span style="color: #080;">&#93;</span><span style="color: #080;">&#41;</span>; <span style="color: #0000FF;">pause</span><span style="color: #080;">&#40;</span><span style="color: #33f;">0.5</span><span style="color: #080;">&#41;</span>; <span style="color: #0000FF;">fprintf</span><span style="color: #080;">&#40;</span><span style="color: #080;">&#91;</span><span style="color:#A020F0;">'\b\b\b\boff\n'</span><span style="color: #080;">&#93;</span><span style="color: #080;">&#41;</span>; <span style="color: #0000FF;">end</span>
on   <span style="color: #080;">&#40;</span>toggles on/off each second<span style="color: #080;">&#41;</span></pre></div></div><p>step 4 (in a loop):</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">&gt;&gt; <span style="color: #0000FF;">fprintf</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'progress:  00%%\n'</span><span style="color: #080;">&#41;</span>; <span style="color: #0000FF;">for</span> n=<span style="color: #33f;">1</span><span style="color: #F0F;">:</span><span style="color: #33f;">10</span>, <span style="color: #0000FF;">pause</span><span style="color: #080;">&#40;</span><span style="color: #33f;">1</span><span style="color: #080;">&#41;</span>; <span style="color: #0000FF;">fprintf</span><span style="color: #080;">&#40;</span><span style="color: #080;">&#91;</span><span style="color:#A020F0;">'\b\b\b\b\b. %d%%\n'</span><span style="color: #080;">&#93;</span>,<span style="color: #33f;">10</span>*n<span style="color: #080;">&#41;</span>; <span style="color: #0000FF;">end</span>
progress<span style="color: #F0F;">:</span> <span style="color: #F0F;">...</span>..<span style="">well</span>, this text will change once a second</pre></div></div><p>The pause command in the example represents a sequence of time-consuming operations. Note that we don&#8217;t need any timer objects, GUI callbacks, class events, Java, com.mathworks.etc here. Just raw C format specifications, doing their dirty deeds since Matlab 5 (or earlier). The general strategy should also work with cprintf, so thanks Yair we can finally see those progressbars grow in any color.</p> ]]></content:encoded> </item> <item><title>By: Helge</title><link>http://undocumentedmatlab.com/blog/cprintf-display-formatted-color-text-in-command-window/#comment-56175</link> <dc:creator>Helge</dc:creator> <pubDate>Wed, 07 Sep 2011 18:10:34 +0000</pubDate> <guid
isPermaLink="false">http://undocumentedmatlab.com/?p=274#comment-56175</guid> <description>From the cprintf syntax example I might guess that each call adds text to the current buffer using one unique 2-parameter style (color and underlined/link). Besides the question whether it is technically possible to switch also the FontName, FontSize, FontWeight etc for each new token before the buffer is terminated and we see the &gt;&gt; prompt again, I am curious if we will ever see some hprintf for HTML-formatted text, to specify text with changing properties using one single command? Yair, would that be an option for cprintf version 2.0?However, don&#039;t feel stressed!-) What you gave us is already cool enough and deeply impressive. After all, my very personal approach is to use the command window only to display plain text, because everything else is (was?) so much easier to display with GUI elements (which already *can* interpret basic HTML in their String property). But from a sportsman&#039;s viewpoint... wow, you are miles ahead!</description> <content:encoded><![CDATA[<p>From the cprintf syntax example I might guess that each call adds text to the current buffer using one unique 2-parameter style (color and underlined/link). Besides the question whether it is technically possible to switch also the FontName, FontSize, FontWeight etc for each new token before the buffer is terminated and we see the &gt;&gt; prompt again, I am curious if we will ever see some hprintf for HTML-formatted text, to specify text with changing properties using one single command? Yair, would that be an option for cprintf version 2.0?</p><p>However, don&#8217;t feel stressed!-) What you gave us is already cool enough and deeply impressive. After all, my very personal approach is to use the command window only to display plain text, because everything else is (was?) so much easier to display with GUI elements (which already *can* interpret basic HTML in their String property). But from a sportsman&#8217;s viewpoint&#8230; wow, you are miles ahead!</p> ]]></content:encoded> </item> <item><title>By: Jon</title><link>http://undocumentedmatlab.com/blog/cprintf-display-formatted-color-text-in-command-window/#comment-56076</link> <dc:creator>Jon</dc:creator> <pubDate>Tue, 06 Sep 2011 18:00:50 +0000</pubDate> <guid
isPermaLink="false">http://undocumentedmatlab.com/?p=274#comment-56076</guid> <description>This function is really amazing!  I cannot understand how MathWorks did not do this already.  Thanks for making it.However, it seems that R2011b (just released) has broken cprintf.  I hope it can be fixed soon.</description> <content:encoded><![CDATA[<p>This function is really amazing!  I cannot understand how MathWorks did not do this already.  Thanks for making it.</p><p>However, it seems that R2011b (just released) has broken cprintf.  I hope it can be fixed soon.</p> ]]></content:encoded> </item> <item><title>By: Mailf</title><link>http://undocumentedmatlab.com/blog/cprintf-display-formatted-color-text-in-command-window/#comment-52430</link> <dc:creator>Mailf</dc:creator> <pubDate>Wed, 27 Jul 2011 15:55:01 +0000</pubDate> <guid
isPermaLink="false">http://undocumentedmatlab.com/?p=274#comment-52430</guid> <description>Really helpful for the community why MathWoks didn&#039;t think about that before???!
Many thanks!</description> <content:encoded><![CDATA[<p>Really helpful for the community why MathWoks didn&#8217;t think about that before???!<br
/> Many thanks!</p> ]]></content:encoded> </item> <item><title>By: Yair Altman</title><link>http://undocumentedmatlab.com/blog/cprintf-display-formatted-color-text-in-command-window/#comment-36740</link> <dc:creator>Yair Altman</dc:creator> <pubDate>Tue, 15 Mar 2011 07:01:13 +0000</pubDate> <guid
isPermaLink="false">http://undocumentedmatlab.com/?p=274#comment-36740</guid> <description>@Giovanni - unfortunately, at the moment I do not know of any way to modify the CW fonts...</description> <content:encoded><![CDATA[<p>@Giovanni &#8211; unfortunately, at the moment I do not know of any way to modify the CW fonts&#8230;</p> ]]></content:encoded> </item> <item><title>By: Giovanni Intagliata-Hooker</title><link>http://undocumentedmatlab.com/blog/cprintf-display-formatted-color-text-in-command-window/#comment-36720</link> <dc:creator>Giovanni Intagliata-Hooker</dc:creator> <pubDate>Tue, 15 Mar 2011 03:14:12 +0000</pubDate> <guid
isPermaLink="false">http://undocumentedmatlab.com/?p=274#comment-36720</guid> <description>I am waiting with baited breath for an update that allows one to change the FontName within the CW. There is nothing on the net on how to do it without using plots...Good work!</description> <content:encoded><![CDATA[<p>I am waiting with baited breath for an update that allows one to change the FontName within the CW. There is nothing on the net on how to do it without using plots&#8230;</p><p>Good work!</p> ]]></content:encoded> </item> <item><title>By: Yair Altman</title><link>http://undocumentedmatlab.com/blog/cprintf-display-formatted-color-text-in-command-window/#comment-30737</link> <dc:creator>Yair Altman</dc:creator> <pubDate>Sun, 23 Jan 2011 06:50:54 +0000</pubDate> <guid
isPermaLink="false">http://undocumentedmatlab.com/?p=274#comment-30737</guid> <description>@Kathy - as far as I know italics are not supported</description> <content:encoded><![CDATA[<p>@Kathy &#8211; as far as I know italics are not supported</p> ]]></content:encoded> </item> </channel> </rss>

<!-- W3 Total Cache: Minify debug info:
Engine:             disk: basic
Theme:              b7666
Template:           single
-->
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Served from: undocumentedmatlab.com @ 2012-02-09 06:34:50 -->

<!-- W3 Total Cache: Page cache debug info:
Engine:             disk: enhanced
Cache key:          blog/cprintf-display-formatted-color-text-in-command-window/feed/_index.xml_gzip
Caching:            enabled
Status:             not cached
Creation Time:      0.701s
Header info:
X-Pingback:         http://undocumentedmatlab.com/blog/xmlrpc.php
Set-Cookie:         wpgb_visit_last_php-default=1328794490; expires=Fri, 08-Feb-2013 13:34:50 GMT; path=/
Link:               <http://undocumentedmatlab.com/?p=274>; rel=shortlink
Content-Type:       text/xml; charset=UTF-8
Last-Modified:      Thu, 09 Feb 2012 13:34:50 GMT
Vary:               Accept-Encoding, Cookie
Expires:            Thu, 09 Feb 2012 14:34:50 GMT
Pragma:             public
Cache-Control:      public, must-revalidate, proxy-revalidate
Etag:               90bd304f428807eaf190186ac4620b2f
Content-Encoding:   gzip
-->
