<?xml version="1.0"?>
<rss version="2.0" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:media="http://search.yahoo.com/mrss/" xmlns:yt="http://gdata.youtube.com/schemas/2007">
   <channel>
      <title>MATLAB Central Blogs copy</title>
      <description>Pipes Output</description>
      <link>http://pipes.yahoo.com/pipes/pipe.info?_id=e72c9f53f10ba5cad505dbbed8d501cb</link>
      <pubDate>Sun, 22 Nov 2009 03:47:36 -0800</pubDate>
      <generator>http://pipes.yahoo.com/pipes/</generator>
      <item>
         <title>Extracting dot locations from a graphic</title>
         <link>http://feedproxy.google.com/~r/SteveOnImageProcessing/~3/G3rwjkJNQAM/</link>
         <description>I was looking at the image below on a web page recently and I decided to extract the locations of all the dots. I thought the procedure might make a nice little end-of-the-week how-to post. % Did you know that imread can read directly from [...]</description>
         <guid isPermaLink="false">http://blogs.mathworks.com/steve/2009/11/20/extracting-dot-locations-from-a-graphic/</guid>
         <pubDate>Fri, 20 Nov 2009 11:56:36 -0800</pubDate>
         <content:encoded><![CDATA[<div class="content"><p>I was looking at the image below on a <a rel="nofollow" target="_blank" href="http://cgm.cs.mcgill.ca/~godfried/teaching/projects97/belair/alpha.html">web page</a> recently and I decided to extract the locations of all the dots. I thought the procedure might make a nice little end-of-the-week how-to post. </p><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);"><span style="color:#228B22;">% Did you know that imread can read directly from a URL?</span>
url = <span style="color:#A020F0;">'http://cgm.cs.mcgill.ca/~godfried/teaching/projects97/belair/example1.gif'</span>;
[X, map] = imread(url);
imshow(X, map)</pre><img vspace="5" hspace="5" src="http://blogs.mathworks.com/images/steve/2009/dot_locations_01.png"> <p>First question to answer: What is the index of the color used for the dots? One easy way to go is to use <a rel="nofollow" target="_blank" href="http://www.mathworks.com/access/helpdesk/help/toolbox/images/imtool.html"><tt>imtool</tt></a>. </p> <p>Here's a screenshot:</p> <p><img vspace="5" hspace="5" src="http://blogs.mathworks.com/images/steve/2009/imtool-screen-shot.png"> </p> <p>As you can see, when I placed the mouse pointer over the center of one of the dots, the pixel info display at the lower left showed that the index value was 1, and the corresponding colormap color was [1.00, 0.78, 0.00]. </p> <p>Now that we know the index value, we can easily make a binary image of just the interior of the dots.</p><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);">bw = X == 1;
imshow(bw)</pre><img vspace="5" hspace="5" src="http://blogs.mathworks.com/images/steve/2009/dot_locations_02.png"> <p>Now we can compute the centroids of the dots.</p><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);">s = regionprops(bw, <span style="color:#A020F0;">'Centroid'</span>)</pre><pre style="font-style:oblique;">
s = 122x1 struct array with fields: Centroid </pre><p>The line above is a new syntax for <a rel="nofollow" target="_blank" href="http://www.mathworks.com/access/helpdesk/help/toolbox/images/regionprops.html"><tt>regionprops</tt></a> that we introduced earlier this year in R2009a. Previously, you always had to compute a label matrix first using <a rel="nofollow" target="_blank" href="http://www.mathworks.com/access/helpdesk/help/toolbox/images/bwlabel.html"><tt>bwlabel</tt></a> and then pass that label matrix to <tt>regionprops</tt>. Now <tt>regionprops</tt> can do this computation directly on the binary image. Since the label matrix is not computed, this new syntax uses less memory and usually runs faster than the old version. </p> <p>For those of you using an older version, do this instead:</p><pre> L = bwlabel(bw); s = regionprops(L, 'Centroid');</pre><p>To show the results, display the image and then superimpose the centroid locations.</p><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);">imshow(X, map)
hold <span style="color:#A020F0;">on</span>
<span style="color:#0000FF;">for</span> k = 1:numel(s) centroid_k = s(k).Centroid; plot(centroid_k(1), centroid_k(2), <span style="color:#A020F0;">'b.'</span>);
<span style="color:#0000FF;">end</span>
hold <span style="color:#A020F0;">off</span></pre><img vspace="5" hspace="5" src="http://blogs.mathworks.com/images/steve/2009/dot_locations_03.png"> <p>Hmm. It looks we got only one dot at some of those locations. Use the zoom button on the Figure Window toolbar to zoom in. Or you can do it noninteractively: </p><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);">axis([50 100 0 50])</pre><img vspace="5" hspace="5" src="http://blogs.mathworks.com/images/steve/2009/dot_locations_04.png"> <p>Yep. For overlapping circles, we are only getting one location. The reason is that the interiors of the overlapping circles are 8-connected to each other, so they are regarded by <tt>regionprops</tt> as single regions. To get two locations for these overlapping circles, we have to label the regions using 4-connectivity instead of 8-connectivity. </p> <p>To do this we have to compute the connected components in a separate step and then call <tt>regionprops</tt>. </p><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);">cc = bwconncomp(bw, 4);
s = regionprops(cc, <span style="color:#A020F0;">'Centroid'</span>);</pre><p><a rel="nofollow" target="_blank" href="http://www.mathworks.com/access/helpdesk/help/toolbox/images/bwconncomp.html"><tt>bwconncomp</tt></a> is also new to R2009a. Users of R2008b and earlier can do: </p><pre> L = bwlabel(bw, 4); s = regionprops(L, 'Centroid');</pre><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);">imshow(X, map)
hold <span style="color:#A020F0;">on</span>
<span style="color:#0000FF;">for</span> k = 1:numel(s) centroid_k = s(k).Centroid; plot(centroid_k(1), centroid_k(2), <span style="color:#A020F0;">'b.'</span>);
<span style="color:#0000FF;">end</span>
hold <span style="color:#A020F0;">off</span>
axis([50 100 0 50])</pre><img vspace="5" hspace="5" src="http://blogs.mathworks.com/images/steve/2009/dot_locations_05.png"> <p>Much better.</p> <p>This little example showed several useful things:</p> <div> <ul> <li>Reading an image directly from a URL</li> <li>Using <tt>imtool</tt> to inspect individual pixel values </li> <li>Using the new, more efficient syntax of <tt>regionprops</tt></li> <li>Using the new <tt>bwconncomp</tt></li> <li>Superimposing plots on an image</li> </ul> </div> <p>Have a happy weekend!</p><p style="text-align:right;font-size:xx-small;font-weight:lighter;font-style:italic;color:gray;"><br /><a rel="nofollow"><span style="font-size:x-small;font-style:italic;">Get the MATLAB code <noscript>(requires JavaScript)</noscript></span></a><br /><br /> Published with MATLAB&reg; 7.9<br /></p>
</div>
<img src="http://feeds.feedburner.com/~r/SteveOnImageProcessing/~4/G3rwjkJNQAM" height="1" width="1"/>]]></content:encoded>
         <category>Uncategorized</category>
      </item>
      <item>
         <title>Basics: Volume visualization: 6/9 Displays quiver3 and coneplot</title>
         <link>http://feedproxy.google.com/~r/DougsMatlabVideoTutorials/~3/QTB-AzSWM8U/</link>
         <description>This short video is the sixth of a series of nine that talks about volume visualization. Patrick gave this talk internally to help technical support engineers understand capabilities of MATLAB for volume visualization. I like his slow, clear, methodical presentation with great visualizations. It is the first time I have deeply understood some of the volume [...]</description>
         <guid isPermaLink="false">http://blogs.mathworks.com/videos/2009/11/20/basics-volume-visualization-69-displays-quiver3-and-coneplot/</guid>
         <pubDate>Fri, 20 Nov 2009 11:48:14 -0800</pubDate>
         <content:encoded><![CDATA[This short video is the sixth of a series of nine that talks about volume visualization. Patrick gave this talk internally to help technical support engineers understand capabilities of MATLAB for volume visualization.
<p>
<p>
I like his slow, clear, methodical presentation with great visualizations. It is the first time I have deeply understood some of the volume visualization techniques we have. <p>
<ul> <li><a rel="nofollow" target="_blank" href="http://blogs.mathworks.com/videos/2009/10/23/basics-volume-visualization-19-defining-scalar-and-vector-fields/">1 of 9 Definitions for scalar and vector fields. </a></li> <li><a rel="nofollow" target="_blank" href="http://blogs.mathworks.com/videos/2009/10/30/basics-volume-visualization-29-examples-of-scalar-and-vector-fields/">2 of 9 Examples of scalar and vector fields (temperature in a room vs air currents) </a></li> <li><a rel="nofollow" target="_blank" href="http://blogs.mathworks.com/videos/2009/11/06/basics-volume-visualization-39-display-of-scatter3-and-slice-plots/">3 of 9 Displays scatter3 and slice plots. </a></li> <li><a rel="nofollow" target="_blank" href="http://blogs.mathworks.com/videos/2009/11/11/basics-volume-visualization-49-display-of-contourslice-and-isosurface/">4 of 9 Displays contourslice and isosurface.</a> </li> <li><a rel="nofollow" target="_blank" href="http://blogs.mathworks.com/videos/2009/11/17/basics-volume-visualization-59-making-a-3-d-plot-pretty-with-lighting-shading-interpolation-etc/">5 of 9 Making a 3-d plot &#8216;pretty&#8217; with lighting, shading, interpolation, etc&#8230;</a></li> <li>6 of 9 Displays quiver3 and coneplot </li>
</ul> <div class="video" style="width:660;height:410;">   <div id="videoalternate170" style="width:660px;height:410px;"> <a rel="nofollow" target="_blank" href="http://www.adobe.com/go/getflashplayer"> <img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player"/> </a> </div> </div>
<img src="http://feeds.feedburner.com/~r/DougsMatlabVideoTutorials/~4/QTB-AzSWM8U" height="1" width="1"/>]]></content:encoded>
      </item>
      <item>
         <title>Regular Expressions…a Cheat Sheet!</title>
         <link>http://feedproxy.google.com/~r/mathworks/pick/~3/RzctSph0YN4/</link>
         <description>In my last Pick, I singled out someone who has contributed widely to image-processing discussions on the CSSM newsgroup. Today, I want to recognize a stalwart contributor to the MATLAB community, both through CSSM and through his numerous submissions to the MATLAB Central File [...]</description>
         <guid isPermaLink="false">http://blogs.mathworks.com/pick/2009/11/20/regular-expressionsa-cheat-sheet/</guid>
         <pubDate>Fri, 20 Nov 2009 06:05:38 -0800</pubDate>
         <content:encoded><![CDATA[<div class="content"><p>In <a rel="nofollow" target="_blank" href="http://blogs.mathworks.com/pick/2009/11/06/segmenting-coinsa-tutorial-on-blob-analysis/">my last Pick</a>, I singled out someone who has contributed widely to image-processing discussions on the <a rel="nofollow" target="_blank" href="http://www.mathworks.com/matlabcentral/newsreader">CSSM newsgroup</a>. Today, I want to recognize a stalwart contributor to the MATLAB community, both through CSSM and through his numerous submissions to the MATLAB Central File Exchange. Anyone who has spent time posing or answering questions on CSSM knows of <a rel="nofollow" target="_blank" href="http://www.mathworks.com/matlabcentral/fileexchange/authors/4309">us</a>. And though he has labeled all of his 41 submissions as "pedestrian," most are anything but. </p> <p>Today's Pick comes to us from us. (Sounds circular, but power-user us apparently doesn't like capitals--or three-letter names!). In <a rel="nofollow" target="_blank" href="http://www.mathworks.com/matlabcentral/fileexchange/20589-rex-a-pedestrian-regular-expression-operator-synopsis-generator">rex: a pedestrian regular expression operator synopsis generator</a>, us has provided a very handy cheat sheet, of sorts, for creating <a rel="nofollow" target="_blank" href="http://www.mathworks.com/access/helpdesk/help/techdoc/matlab_prog/f0-42649.html">Regular Expressions</a>. For those of you who haven't yet delved the mysteries of regular expressions, they are powerful devices for searching or manipulating strings. But they can be cryptic to create or to decipher. Us's rex is a single-page reference for writing regular expressions. The commands can be written to the Command Window, or displayed in a listbox: </p> <p><img vspace="5" hspace="5" src="http://blogs.mathworks.com/pick/../images/pick/rex_potw.png"> </p> <p>Many of us's files are Pickworthy. His functions are broadly useful, and his code is powerful, concise, and well-written. Give his files a browse--there's something there for everyone! </p> <p><a rel="nofollow" target="_blank" href="http://blogs.mathworks.com/pick/?p=2498#respond">Comments?</a></p><p style="text-align:right;font-size:xx-small;font-weight:lighter;font-style:italic;color:gray;"><br /><a rel="nofollow"><span style="font-size:x-small;font-style:italic;">Get the MATLAB code <noscript>(requires JavaScript)</noscript></span></a><br /><br /> Published with MATLAB&reg; 7.8<br /></p>
</div>
<img src="http://feeds.feedburner.com/~r/mathworks/pick/~4/RzctSph0YN4" height="1" width="1"/>]]></content:encoded>
         <category>Picks</category>
      </item>
      <item>
         <title>Coordinating Zero Removals from Multiple Arrays</title>
         <link>http://feedproxy.google.com/~r/mathworks/loren/~3/bmya0EQb9sw/</link>
         <description>I've fielded some questions recently about how to coordinate multiple arrays changing simultaneously. One example is removing elements for two arrays in the case where either array holds a zero for the location. This is a good [...]</description>
         <guid isPermaLink="false">http://blogs.mathworks.com/loren/2009/11/19/coordinating-zero-removals-from-multiple-arrays/</guid>
         <pubDate>Thu, 19 Nov 2009 13:34:57 -0800</pubDate>
         <content:encoded><![CDATA[<div class="content"><p>I've fielded some questions recently about how to coordinate multiple arrays changing simultaneously. One example is removing elements for two arrays in the case where either array holds a zero for the location. This is a good opportunity to reiterate the use of logical arrays and some useful associated functions (such as <tt>any</tt> and <tt>all</tt>). </p>  <h3>Contents</h3> <div> <ul> <li><a rel="nofollow" href="#1">Identify Pairs to Remove</a></li> <li><a rel="nofollow" href="#3">First Algorithm</a></li> <li><a rel="nofollow" href="#5">Second Algorithm</a></li> <li><a rel="nofollow" href="#7">Always Tradeoffs</a></li> </ul> </div> <h3>Identify Pairs to Remove<a rel="nofollow" name="1"></a></h3> <p>Let's say I have 2 arrays</p><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);">a = [ 1 4 9 0 25 0 49 0]
b = [ 1 0 3 0 0 6 7 8]</pre><pre style="font-style:oblique;">a = 1 4 9 0 25 0 49 0
b = 1 0 3 0 0 6 7 8
</pre><p>and I would like to delete the corresponding elements in <tt>a</tt> and <tt>b</tt> when either of them contains a zero value. </p> <h3>First Algorithm<a rel="nofollow" name="3"></a></h3> <p>There are several possible algorithms, each with their own trade-offs. Here's the first one.</p><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);">anyzero = any([a;b] == 0)
a(anyzero) = []
b(anyzero) = []</pre><pre style="font-style:oblique;">anyzero = 0 1 0 1 1 1 0 1
a = 1 9 49
b = 1 3 7
</pre><p>This algorithm combines the two arrays into one, a potentially costly move if the arrays are large. Then check for values that equal zero. And finally, check columnwise, using the function <a rel="nofollow" target="_blank" href="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/any.html"><tt>any</tt></a>, to identify the columns that have at least one zero. Finally, use this array of logical indices to delete the appropriate elements of <tt>a</tt> and <tt>b</tt>. </p> <h3>Second Algorithm<a rel="nofollow" name="5"></a></h3> <p>This algorithm (courtesy of Mirek L. in <a rel="nofollow" target="_blank" href="http://www.mathworks.com/matlabcentral/newsreader/view_thread/263299">this post</a> doesn't suffer from combining the two arrays. </p><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);">x1 = a(a.*b ~= 0)
y1 = b(a.*b ~= 0)</pre><pre style="font-style:oblique;">x1 = 1 9 49
y1 = 1 3 7
</pre><p>But it calculates the same temporary array twice (and it's the size of one of the vectors). To be able to recalculate the temporary array this way, I can't overwrite the initial arrays as you see in the first algorithm. And finally, is there is a <tt>NaN</tt> or <tt>Inf</tt> corresponding to a <tt>0</tt>, this algorithm won't find it. </p> <h3>Always Tradeoffs<a rel="nofollow" name="7"></a></h3> <p>There are always tradeoffs to make like the ones I mention here, at least when I program. How do <b>you</b> choose which tradeoffs to make? Which one would you choose here? Or would you choose an entirely different algorithm (which I hope you'll post). Let us know <a rel="nofollow" target="_blank" href="http://blogs.mathworks/com/loren/?p=206#respond">here</a>. </p><p style="text-align:right;font-size:xx-small;font-weight:lighter;font-style:italic;color:gray;"><br /><a rel="nofollow"><span style="font-size:x-small;font-style:italic;">Get the MATLAB code <noscript>(requires JavaScript)</noscript></span></a><br /><br /> Published with MATLAB&reg; 7.9<br /></p>
</div>
<img src="http://feeds.feedburner.com/~r/mathworks/loren/~4/bmya0EQb9sw" height="1" width="1"/>]]></content:encoded>
      </item>
      <item>
         <title>Back-Seat Driver: Simulink Tips for Efficient Model Navigation</title>
         <link>http://feedproxy.google.com/~r/SethOnSimulink/~3/dt5NZIHM-Sc/</link>
         <description>Does this ever happen to you? You are sitting in a
meeting looking up at the projected image of your coworker’s computer desktop. They are navigating through {a web page, a Simulink model, or computer
settings}. You can see a faster, better, more efficient way to complete the
task. You as the observer have two options: 1) politely bite [...]</description>
         <guid isPermaLink="false">http://blogs.mathworks.com/seth/2009/11/18/back-seat-driver-simulink-tips-for-efficient-model-navigation/</guid>
         <pubDate>Tue, 17 Nov 2009 19:45:50 -0800</pubDate>
         <content:encoded><![CDATA[<p><em>Does this ever happen to you? </em>You are sitting in a
meeting looking up at the projected image of your coworker’s computer desktop. They are navigating through {a web page, a Simulink model, or computer
settings}. You can see a faster, better, more efficient way to complete the
task. You as the observer have two options: 1) politely bite your lip or 2)
become the back-seat driver and scream out corrective commands like “up, up,
up... to the right, right, left... click the thing...open... control-k...arg!”</p> <p>This happens to me some times... especially with Simulink
models. I want to share with you two Simulink tips that I wish everyone knew.</p> <p><strong>Tip: Navigating your model – window reuse, and escape.</strong></p> <p>I spend much of my day looking at models I did not build. Finding your way around large models can be slow due to the many layers of
subsystems between the top of the model and the leaf component you are working
on. There are two parts to this tip.</p> <p><em>Part one is setting window reuse.</em> Make sure the
model is set for window reuse. I rarely need to look at two different systems
at the same time, so my preference is to set Simulink to reuse the windows as I
navigate the diagram. A close alternative is to use mixed.</p> <p><img src="http://blogs.mathworks.com/images/seth/2009Q4/simulinkPreferences.png" alt="Simulink Preferences control window reuse."></p> <p>Part two is using the escape key. Diving down through
layers of a model is as easy as double clicking on a subsystem. What do you do
when you want to go back up a level? While you can reach for the arrows on the
toolbar to go back, or up a level, I use the escape key. Escape will bring you
to the level above the current level. This even works if you have opened a
reference model, Stateflow chart, Embedded MATLAB function blocks and block
dialogs!</p> <p><strong><img src="http://blogs.mathworks.com/images/seth/2009Q4/escNavigate.gif" alt="Annimation showing the easy navigation accross many levels of model hierarchy."></strong></p> <p><strong>What do you know?</strong></p> <p>What accelerators do you use to work more efficiently? What
do you yell when back-seat driving? Leave a <a rel="nofollow"
 target="_blank" href="http://blogs.mathworks.com/seth/?p=74&amp;#comment">comment here</a> and
tell me about it.</p><img src="http://feeds.feedburner.com/~r/SethOnSimulink/~4/dt5NZIHM-Sc" height="1" width="1"/>]]></content:encoded>
      </item>
      <item>
         <title>Basics: Volume visualization: 5/9 Making a 3-d plot ‘pretty’ with lighting, shading, interpolation, etc…</title>
         <link>http://feedproxy.google.com/~r/DougsMatlabVideoTutorials/~3/uxD6hn71EQs/</link>
         <description>This short video is the fifth of a series of nine that talks about volume visualization. Patrick gave this talk internally to help technical support engineers understand capabilities of MATLAB for volume visualization. I like his slow, clear, methodical presentation with great visualizations. It is the first time I have deeply understood some of the volume [...]</description>
         <guid isPermaLink="false">http://blogs.mathworks.com/videos/2009/11/17/basics-volume-visualization-59-making-a-3-d-plot-pretty-with-lighting-shading-interpolation-etc/</guid>
         <pubDate>Tue, 17 Nov 2009 08:40:49 -0800</pubDate>
         <content:encoded><![CDATA[This short video is the fifth of a series of nine that talks about volume visualization. Patrick gave this talk internally to help technical support engineers understand capabilities of MATLAB for volume visualization.
<p>
<p>
I like his slow, clear, methodical presentation with great visualizations. It is the first time I have deeply understood some of the volume visualization techniques we have. <p>
<ul> <li><a rel="nofollow" target="_blank" href="http://blogs.mathworks.com/videos/2009/10/23/basics-volume-visualization-19-defining-scalar-and-vector-fields/">1 of 9 Definitions for scalar and vector fields. </a></li> <li><a rel="nofollow" target="_blank" href="http://blogs.mathworks.com/videos/2009/10/30/basics-volume-visualization-29-examples-of-scalar-and-vector-fields/">2 of 9 Examples of scalar and vector fields (temperature in a room vs air currents) </a></li> <li><a rel="nofollow" target="_blank" href="http://blogs.mathworks.com/videos/2009/11/06/basics-volume-visualization-39-display-of-scatter3-and-slice-plots/">3 of 9 Displays scatter3 and slice plots. </a></li> <li><a rel="nofollow" target="_blank" href="http://blogs.mathworks.com/videos/2009/11/11/basics-volume-visualization-49-display-of-contourslice-and-isosurface/">4 of 9 Displays contourslice and isosurface.</a> </li> <li>5 of 9 Making a 3-d plot &#8216;pretty&#8217; with lighting, shading, interpolation, etc&#8230;</li> </ul> <div class="video" style="width:660;height:410;">   <div id="videoalternate169" style="width:660px;height:410px;"> <a rel="nofollow" target="_blank" href="http://www.adobe.com/go/getflashplayer"> <img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player"/> </a> </div> </div>
<img src="http://feeds.feedburner.com/~r/DougsMatlabVideoTutorials/~4/uxD6hn71EQs" height="1" width="1"/>]]></content:encoded>
      </item>
      <item>
         <title>Publish to PDF</title>
         <link>http://feedproxy.google.com/~r/mathworks/desktop/~3/cfqXO81wl0U/</link>
         <description>Sometimes one of my colleagues comes up with a big idea that&amp;#8217;s so brilliant, it can be succinctly summarized in a small phrase that downplays its impact. Publish to PDF pretty much says it all. In MATLAB R2009b you can now publish your MATLAB code directly to a PDF-file. If you&amp;#8217;re like me, you [...]</description>
         <guid isPermaLink="false">http://blogs.mathworks.com/desktop/2009/11/16/publish-to-pdf/</guid>
         <pubDate>Mon, 16 Nov 2009 06:06:37 -0800</pubDate>
         <content:encoded><![CDATA[<p>Sometimes one of my colleagues comes up with a big idea that&#8217;s so brilliant, it can be succinctly summarized in a small phrase that downplays its impact. <a rel="nofollow" target="_blank" href="http://www.mathworks.com/access/helpdesk/help/techdoc/rn/br5ktrh-1.html#br5ktri-27"><em>Publish to PDF</em></a> pretty much says it all. In MATLAB R2009b you can now publish your MATLAB code directly to a PDF-file. </p>
<p>If you&#8217;re like me, you probably used to publish to doc and then use Google docs to convert it to a PDF. Well now you can go to PDF directly, and get a higher quality document than you would by going through Word and then to pdf.</p>
<p>That&#8217;s pretty much the whole peanut butter sandwhich right there. The easiest way to set this up is through a Publish Configuration. </p>
<div align="center"><img src="http://blogs.mathworks.com/images/desktop/michael_katz_publish_to_pdf/publish_to_pdf_small_f.png" alt="Publish to PDF from a publish configuration"></div>
<p>Here is an image of the output of the <a rel="nofollow" target="_blank" href="http://www.mathworks.com/access/helpdesk/help/techdoc/matlab_env/briymz8-1.html#br68y68-1">sine wave publishing demo </a>(click to see a larger version): </p>
<div align="center"><a rel="nofollow" target="_blank" href="http://blogs.mathworks.com/images/desktop/michael_katz_publish_to_pdf/sine_wave_pdf.png"><img src="http://blogs.mathworks.com/images/desktop/michael_katz_publish_to_pdf/sine_wave_pdf.png" alt="Published PDF of sine wave demo" width="550"></a></div>
<p>.</p>
<p>You can also watch this <a rel="nofollow" target="_blank" href="http://www.mathworks.com/support/2009b/matlab/7.9/demos/new-matlab-publishing-features-in-r2009b.html">lovely video</a> on how this new feature works.</p>
<img src="http://feeds.feedburner.com/~r/mathworks/desktop/~4/cfqXO81wl0U" height="1" width="1"/>]]></content:encoded>
         <category>Publish</category>
      </item>
      <item>
         <title>Contest: Flood wrap-up</title>
         <link>http://feedproxy.google.com/~r/DougsMatlabVideoTutorials/~3/T4Ew1Hxysv0/</link>
         <description>Here is the wrap up of the MATLAB programming contest that we just ran. var flashvars = {}; [...]</description>
         <guid isPermaLink="false">http://blogs.mathworks.com/videos/2009/11/13/contest-flood-wrap-up/</guid>
         <pubDate>Fri, 13 Nov 2009 10:25:57 -0800</pubDate>
         <content:encoded><![CDATA[Here is the wrap up of the <a rel="nofollow" target="_blank" href="http://www.mathworks.com/contest/flooding/rules.html">MATLAB programming contest that we just ran</a>. <div class="video" style="width:660;height:410;">   <div id="videoalternate175" style="width:660px;height:410px;"> <a rel="nofollow" target="_blank" href="http://www.adobe.com/go/getflashplayer"> <img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player"/> </a> </div> </div> Looking at the entries, I wanted to do a comparison of the winning entry and the 1000 node winner. Looking at all the boards, they were actually fairly close on many of entries:
<p>
<img src='http://blogs.mathworks.com/videos/../images/videos/2009/11/contestdifference.jpg' alt='contestdifference.jpg'/>
<p> <p>
However, we can see that on some of the boards, the winning entry did significantly better. The boards that it won on were those with the large valued 80&#8217;s randomly around the board.
<p>
<img src='http://blogs.mathworks.com/videos/../images/videos/2009/11/contestfinalbetter.jpg' alt='contestfinalbetter.jpg'/>
<p> Surprising to me, the 1000 node solver did noticably better on a couple of the tall skinny boards like this:
<p>
<img src='http://blogs.mathworks.com/videos/../images/videos/2009/11/contest1000beter.jpg' alt='contest1000beter.jpg'/>
<p> That leaves me wondering if someone could have done a quick check to see if the board had 30 colors or so, and then tried the simpler solver. It looks like this would have made some significant gains&#8230; A good contest, congratulations to all that participated.<img src="http://feeds.feedburner.com/~r/DougsMatlabVideoTutorials/~4/T4Ew1Hxysv0" height="1" width="1"/>]]></content:encoded>
      </item>
      <item>
         <title>This “Peaks” My Interest</title>
         <link>http://feedproxy.google.com/~r/mathworks/pick/~3/QzFwQb0PbX8/</link>
         <description>Jiro's pick this week is PeakFinder by Nate Yoder. &quot;What? Another peak finder?&quot; you might say. Some of you may classify this as one of those utilities that has been created by many people over the years, like sudoku and waitbar. Well, [...]</description>
         <guid isPermaLink="false">http://blogs.mathworks.com/pick/2009/11/13/this-peaks-my-interest/</guid>
         <pubDate>Fri, 13 Nov 2009 05:46:00 -0800</pubDate>
         <content:encoded><![CDATA[<div class="content"><p><a rel="nofollow" target="_blank" href="http://www.mathworks.com/matlabcentral/fileexchange/authors/15007">Jiro</a>'s pick this week is <a rel="nofollow" target="_blank" href="http://www.mathworks.com/matlabcentral/fileexchange/25500-peakfinder"><tt>PeakFinder</tt></a> by <a rel="nofollow" target="_blank" href="http://www.mathworks.com/matlabcentral/fileexchange/authors/39794">Nate Yoder</a>. </p> <p><i>"What? Another peak finder?"</i> you might say. Some of you may classify this as one of those utilities that has been created by many people over the years, like <a rel="nofollow" target="_blank" href="http://www.mathworks.com/matlabcentral/fileexchange/?term=tag:&#34;sudoku&#34;">sudoku</a> and <a rel="nofollow" target="_blank" href="http://www.mathworks.com/matlabcentral/fileexchange/?term=tag:&#34;waitbar&#34;">waitbar</a>. Well, peak finding happens to be something dear to my heart. </p> <p>I have been using MATLAB for almost 10 years since my first year of graduate school. I initially learned by trying to decipher my advisor's code. One day, I was struggling to write some code for finding peaks in my data. </p><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);"><span style="color:#228B22;">% Sample data</span>
t = 0:0.01:10;
x = sin(2*t) - 3*cos(3.8*t);</pre><p>That's when my advisor showed me his code:</p><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);">dx = diff(x); <span style="color:#228B22;">% get differences between consecutive points</span>
pkIDX = (dx(1:end-1) &gt;= 0) &amp; (dx(2:end) &lt; 0); <span style="color:#228B22;">% look for slope changes</span>
pkIDX = [dx(1)&lt;0, pkIDX, dx(end)&gt;=0]; <span style="color:#228B22;">% deal with edges</span>
plot(t, x, t(pkIDX), x(pkIDX), <span style="color:#A020F0;">'ro'</span>);</pre><img vspace="5" hspace="5" src="http://blogs.mathworks.com/images/pick/potw_peakfinder_01.png"> <p>This was an eye-opener and was the moment I experienced the power of vector operation for the first time. The way I code in MATLAB had changed from that point on. ... So when I see "peak finding", it brings back memories. </p> <p>There are quite a few File Exchange entries for finding peaks (and valleys), including two previous POTW selections: <a rel="nofollow" target="_blank" href="http://blogs.mathworks.com/pick/2004/03/17/find-spikes-in-data/"><tt>FPEAK</tt></a> and <a rel="nofollow" target="_blank" href="http://blogs.mathworks.com/pick/2008/05/09/finding-local-extrema/"><tt>EXTREMA</tt></a>. But I really like <tt>peakfinder</tt> by Nate. Not only does his code deal with noisy data (my algorithm above will be useless if the signal is noisy), but also his coding practice is quite solid. He has a great help section, robust error-checking of input arguments, and variable input and output arguments for ease of use. </p><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);">xNoise = x + 0.3*sin(40*t); <span style="color:#228B22;">% add a few more bumps</span>
peakfinder(xNoise);</pre><img vspace="5" hspace="5" src="http://blogs.mathworks.com/images/pick/potw_peakfinder_02.png"> <p>I looked through a few peak finding entries, but I'm sure I may have missed some. Feel free to let me know of others you really like <a rel="nofollow" target="_blank" href="http://blogs.mathworks.com/pick/?p=2494#respond">here</a>. </p><p style="text-align:right;font-size:xx-small;font-weight:lighter;font-style:italic;color:gray;"><br /><a rel="nofollow"><span style="font-size:x-small;font-style:italic;">Get the MATLAB code <noscript>(requires JavaScript)</noscript></span></a><br /><br /> Published with MATLAB&reg; 7.9<br /></p>
</div>
<img src="http://feeds.feedburner.com/~r/mathworks/pick/~4/QzFwQb0PbX8" height="1" width="1"/>]]></content:encoded>
         <category>Picks</category>
      </item>
      <item>
         <title>Empty Arrays with Flow of Control and Logical Operators</title>
         <link>http://feedproxy.google.com/~r/mathworks/loren/~3/o75L3fJJypY/</link>
         <description>After reading last week's post on calculating with empty arrays, one of my colleagues mentioned some other behaviors with empty arrays that have tripped him up in the past. Today I will discuss how empty arrays work in [...]</description>
         <guid isPermaLink="false">http://blogs.mathworks.com/loren/2009/11/12/empty-arrays-with-flow-of-control-and-logical-operators/</guid>
         <pubDate>Thu, 12 Nov 2009 11:54:54 -0800</pubDate>
         <content:encoded><![CDATA[<div class="content"><p>After reading <a rel="nofollow" target="_blank" href="http://blogs.mathworks.com/loren/2009/11/04/calculus-with-empty-arrays/">last week's post</a> on calculating with empty arrays, one of my colleagues mentioned some other behaviors with empty arrays that have tripped him up in the past. Today I will discuss how empty arrays work in the contexts of flow of control expressions (both conditional and looping, i.e., <a rel="nofollow" target="_blank" href="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/if.html"><tt>if</tt></a> and <a rel="nofollow" target="_blank" href="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/while.html"><tt>while</tt></a>) and short-circuit operators (i.e., <a rel="nofollow" target="_blank" href="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/logicaloperatorsshortcircuit.html">&amp;&amp; and | |</a>). </p>  <h3>Contents</h3> <div> <ul> <li><a rel="nofollow" href="#1">Empty Arrays in Flow of Control</a></li> <li><a rel="nofollow" href="#6">Empty Arrays with Logical Operators</a></li> <li><a rel="nofollow" href="#8">Short-circuit Logical Operators (| | and &amp;&amp;)</a></li> <li><a rel="nofollow" href="#11">Examples</a></li> <li><a rel="nofollow" href="#20">References</a></li> <li><a rel="nofollow" href="#21">Empty Thoughts?</a></li> </ul> </div> <h3>Empty Arrays in Flow of Control<a rel="nofollow" name="1"></a></h3> <p>Let me first start with plain empty arrays in flow of control situations. For example, what will this code do?</p><pre> E = []; if E disp('Empty is true') else disp('Empty is false') end</pre><p>Readers who remember my comment on last week's blog will correctly guess that the empty expression for the <tt>if</tt> statement is treated as <tt>false</tt>. Why? The way I think about it is this. If I am looking for locations of some condition in an array, and I don't find them, I end up with an empty output. This very output is the kind of expression I am likely to want to use, somehow, in an <tt>if</tt> statement. Let's try it to be sure. </p><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);">E = [];
<span style="color:#0000FF;">if</span> E disp(<span style="color:#A020F0;">'Empty is true'</span>)
<span style="color:#0000FF;">else</span> disp(<span style="color:#A020F0;">'Empty is false'</span>)
<span style="color:#0000FF;">end</span></pre><pre style="font-style:oblique;">Empty is false
</pre><p>The situation gets a bit more complicated if there is a logical expression for the <tt>if</tt> or <tt>while</tt> statement that has an empty array as one of its elements. Let me show you what I mean. Paraphrasing the documentation, </p><pre> There are some conditions however under which while evaluates as true on an empty array. Two examples of this are</pre><pre> A = []; while all(A), doSomething, end while 1|A, doSomething, end</pre><p>Let's see what's going on in each of these examples. In the first one, the function <tt>all</tt> is being called with an empty input. According to the second reference below (on empty arrays), the function <tt>all</tt> is one of the functions that returns a nonzero value for empty input. Let's see. </p><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);">allE = all(E)
allEislogical = islogical(allE)</pre><pre style="font-style:oblique;">allE = 1
allEislogical = 1
</pre><p>The way I think about this is that there are no <tt>false</tt> values in <tt>E</tt>, hence the <tt>true</tt> result. </p> <h3>Empty Arrays with Logical Operators<a rel="nofollow" name="6"></a></h3> <p>The second expression involves an elementwise logical operator ( | ). In this case, the first part of the expression, <tt>1</tt>, is true, so the second part, after the elementwise <tt>or</tt>, is never evaluated. So the fact that an empty result returns <tt>false</tt> never comes into play here. Why? Because &amp; and | operators short-circuit <i>when and only when they are in the context of <tt>if</tt> or <tt>while</tt> expressions</i>. Otherwise, the elementwise operators do <b>not</b> short-circuit. </p> <p>In contrast, the logical operators, &amp;&amp; and | |, always short-circuit, regardless of context.</p> <h3>Short-circuit Logical Operators (| | and &amp;&amp;)<a rel="nofollow" name="8"></a></h3> <p>The next important idea to remember is that the short-circuit logical operators expect scalars as the inputs for the expressions. This means that an empty array, not being a scalar, may cause you some grief if you are unprepared for that situation. Let me show you what I mean. Compare the following 2 code snippets. </p><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);">true || E</pre><pre style="font-style:oblique;">ans = 1
</pre><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);"><span style="color:#0000FF;">try</span> E || true
<span style="color:#0000FF;">catch</span> ME disp(ME.message)
<span style="color:#0000FF;">end</span></pre><pre style="font-style:oblique;">Operands to the || and &amp;&amp; operators must be convertible to logical scalar values.
</pre><p>In the second snippet, the expression E || true</p> <p>produced an error, because E isn't a scalar value. Once the error occurs, the second operand is never evaluated. Contrast that with the snippet, where the first input evaluates to <tt>true</tt>. Short-circuiting then takes over and the second operand, which would cause an error in this context, is never evaluated. </p> <h3>Examples<a rel="nofollow" name="11"></a></h3> <p>Here are a few more code examples to help you see the patterns. Try to figure out the answers before reading the results.</p><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);"><span style="color:#0000FF;">if</span> [] disp(<span style="color:#A020F0;">'hello'</span>)
<span style="color:#0000FF;">else</span> disp(<span style="color:#A020F0;">'bye'</span>)
<span style="color:#0000FF;">end</span></pre><pre style="font-style:oblique;">bye
</pre><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);">true | []</pre><pre style="font-style:oblique;">ans = []
</pre><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);">[] | true</pre><pre style="font-style:oblique;">ans = []
</pre><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);">true || []</pre><pre style="font-style:oblique;">ans = 1
</pre><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);"><span style="color:#0000FF;">try</span> [] || true
<span style="color:#0000FF;">catch</span> ME disp(ME.message)
<span style="color:#0000FF;">end</span></pre><pre style="font-style:oblique;">Operands to the || and &amp;&amp; operators must be convertible to logical scalar values.
</pre><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);"><span style="color:#0000FF;">if</span> true | [] disp(<span style="color:#A020F0;">'hello'</span>)
<span style="color:#0000FF;">else</span> disp(<span style="color:#A020F0;">'bye'</span>)
<span style="color:#0000FF;">end</span></pre><pre style="font-style:oblique;">hello
</pre><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);"><span style="color:#0000FF;">if</span> [] | true disp(<span style="color:#A020F0;">'hello'</span>)
<span style="color:#0000FF;">else</span> disp(<span style="color:#A020F0;">'bye'</span>)
<span style="color:#0000FF;">end</span></pre><pre style="font-style:oblique;">bye
</pre><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);"><span style="color:#0000FF;">if</span> true || [] disp(<span style="color:#A020F0;">'hello'</span>)
<span style="color:#0000FF;">else</span> disp(<span style="color:#A020F0;">'bye'</span>)
<span style="color:#0000FF;">end</span></pre><pre style="font-style:oblique;">hello
</pre><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);"><span style="color:#0000FF;">try</span> <span style="color:#0000FF;">if</span> [] || true disp(<span style="color:#A020F0;">'hello'</span>) <span style="color:#0000FF;">else</span> disp(<span style="color:#A020F0;">'bye'</span>) <span style="color:#0000FF;">end</span>
<span style="color:#0000FF;">catch</span> ME disp(ME.message)
<span style="color:#0000FF;">end</span></pre><pre style="font-style:oblique;">Operands to the || and &amp;&amp; operators must be convertible to logical scalar values.
</pre><h3>References<a rel="nofollow" name="20"></a></h3> <p>Here are a bunch of references to the MATLAB documentation where all of this information is covered.</p> <div> <ul> <li><a rel="nofollow" target="_blank" href="http://www.mathworks.com/access/helpdesk/help/techdoc/matlab_prog/brqy1c1-1.html">Program Control Statements</a></li> <li><a rel="nofollow" target="_blank" href="http://www.mathworks.com/access/helpdesk/help/techdoc/math/f1-86359.html#f1-86384">Empty Matrices, Scalars, and Vectors</a></li> <li><a rel="nofollow" target="_blank" href="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/while.html">while statements</a></li> <li><a rel="nofollow" target="_blank" href="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/if.html">if statements</a></li> <li><a rel="nofollow" target="_blank" href="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/logicaloperatorselementwise.html">Elementwise Logical Operators</a></li> <li><a rel="nofollow" target="_blank" href="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/logicaloperatorsshortcircuit.html">Short-circuit Logical Operators</a></li> </ul> </div> <h3>Empty Thoughts?<a rel="nofollow" name="21"></a></h3> <p>The behaviors with empties in MATLAB are, I believe, consistent and useful. Nonetheless, the behaviors have lots of details to master and can be confusing. If you have any thoughts on the matter, please respond <a rel="nofollow" target="_blank" href="http://blogs.mathworks.com/loren/?p=205#respond">here</a>. </p><p style="text-align:right;font-size:xx-small;font-weight:lighter;font-style:italic;color:gray;"><br /><a rel="nofollow"><span style="font-size:x-small;font-style:italic;">Get the MATLAB code <noscript>(requires JavaScript)</noscript></span></a><br /><br /> Published with MATLAB&reg; 7.9<br /></p>
</div>
<img src="http://feeds.feedburner.com/~r/mathworks/loren/~4/o75L3fJJypY" height="1" width="1"/>]]></content:encoded>
      </item>
      <item>
         <title>Maybe truecolor is OK after all</title>
         <link>http://feedproxy.google.com/~r/SteveOnImageProcessing/~3/AKrcOlLKj6M/</link>
         <description>Yesterday I posted that I was looking for a replacement for the term truecolor. (I won't repeat the explanation here; take a look at the original post.) Quite a few readers posted interesting and thoughtful ideas. Gene commented and Rob sent me e-mail about the [...]</description>
         <guid isPermaLink="false">http://blogs.mathworks.com/steve/2009/11/12/maybe-truecolor-is-ok-after-all/</guid>
         <pubDate>Thu, 12 Nov 2009 10:14:09 -0800</pubDate>
         <content:encoded><![CDATA[<div class="content"><p><a rel="nofollow" target="_blank" href="http://blogs.mathworks.com/steve/2009/11/11/im-looking-for-a-replacement-for-truecolor/">Yesterday I posted</a> that I was looking for a replacement for the term <i>truecolor</i>. (I won't repeat the explanation here; take a look at the <a rel="nofollow" target="_blank" href="http://blogs.mathworks.com/steve/2009/11/11/im-looking-for-a-replacement-for-truecolor/">original post</a>.) Quite a few readers posted interesting and thoughtful ideas. </p> <p><a rel="nofollow" target="_blank" href="http://blogs.mathworks.com/steve/2009/11/11/im-looking-for-a-replacement-for-truecolor/#comment-22328">Gene commented</a> and <a rel="nofollow" target="_blank" href="http://www.mathworks.com/matlabcentral/fileexchange/authors/35927">Rob</a> sent me e-mail about the use of the term truecolor in remotely sensed imagery. I had been thinking about the term as defining a form of representation: each pixel is a vector of color-space component values. They pointed out to me that a "truecolor image" in remote sensing has a more specific meaning: it is a three-band image in which the bands contain data from the red, green, and blue portions of the visible spectrum (in that order). </p> <p>That caused me to rethink things a little bit. If I'm concerned about the distinction between different kinds of <i>representation</i>, then I can talk about a color image as being <i>multichannel</i> or <i>indexed</i>. That leaves us able to use <i>truecolor</i> to refer a specific kind of multichannel color image. And that has the advantage of leaving our existing doc mostly alone. </p> <p>What do you think?</p> <p>It interests me that my posts about terminology questions always seem to draw a lot of comment. And I appreciate that each time I do it, you teach me good stuff. </p> <p>One of my favorite terminology stories is when <a rel="nofollow" target="_blank" href="http://www.hpl.hp.com/about/bios/ron_schafer.html">Prof. Ron Schafer</a> showed his class a <a rel="nofollow" target="_blank" href="http://en.wikipedia.org/wiki/Sniglet">"Sniglet."</a> (Sniglets, which are made-up words with plausible-sounding definitions, were popular in the 1980s.) Since we were a digital signal processing class, we especially appreciated the definition of the Sniglet <i>point blimfark</i> - the point at which the stagecoach wheels in the movie start to look like they're going backward (otherwise known as <i>aliasing</i>). </p><p style="text-align:right;font-size:xx-small;font-weight:lighter;font-style:italic;color:gray;"><br /><a rel="nofollow"><span style="font-size:x-small;font-style:italic;">Get the MATLAB code <noscript>(requires JavaScript)</noscript></span></a><br /><br /> Published with MATLAB&reg; 7.9<br /></p>
</div>
<img src="http://feeds.feedburner.com/~r/SteveOnImageProcessing/~4/AKrcOlLKj6M" height="1" width="1"/>]]></content:encoded>
         <category>Uncategorized</category>
      </item>
      <item>
         <title>I’m looking for a replacement for “truecolor”</title>
         <link>http://feedproxy.google.com/~r/SteveOnImageProcessing/~3/WZp6uTnfaHk/</link>
         <description>The Image Processing Toolbox has terminology conventions for four different image types: Binary images Gray-scale images Indexed images [...]</description>
         <guid isPermaLink="false">http://blogs.mathworks.com/steve/2009/11/11/im-looking-for-a-replacement-for-truecolor/</guid>
         <pubDate>Wed, 11 Nov 2009 07:31:18 -0800</pubDate>
         <content:encoded><![CDATA[<div class="content"><p>The Image Processing Toolbox has terminology conventions for four different image types:</p> <div> <ul> <li>Binary images</li> <li>Gray-scale images</li> <li>Indexed images</li> <li>Truecolor images</li> </ul> </div> <p>You'll also frequently see the term <i>RGB image</i>, which is shorthand for a truecolor image using an RGB color space. (See the <a rel="nofollow" target="_blank" href="http://www.mathworks.com/access/helpdesk/help/toolbox/images/f14-13543.html">User Guide section on image types</a>.) </p> <p>Over the last few years I've become increasingly dissatisfied with the term <i>truecolor</i>. </p> <p>Wikipedia has a <a rel="nofollow" target="_blank" href="http://en.wikipedia.org/wiki/Truecolor">brief article on truecolor</a>. The article says the term describes a "method of representing and storing graphical image information." It goes on to say that a truecolor representation is one that either: </p> <p>(a) can represent a large number of colors, typically at least 2^24.</p> <p>(b) does not use a color look-up table ("colormap" in MATLAB terminology)</p> <p>Curiously, the article refers to (a) and (b) as "equivalent" statements.</p> <p>Defining an image representation method in terms of whether it represents a lot of colors is too vague to be very useful in my view. Defining a representation in terms of a characteristic it does not possess (that is, a truecolor representation does not use a color look-up table) is similarly vague. </p> <p>Also, as I learn more about color science I've grown uncomfortable with the idea that any computer or mathematical representation of color can really be called "true color." </p> <p>Here's the definition I really want to see:</p> <p><i><b>[blank]</b> is a method of representing image information in which each image pixel is stored as a vector of color-space component values.</i></p> <p>But what's a good term to go along with this definition? Help me fill in the blank by commenting with your thoughts.</p><p style="text-align:right;font-size:xx-small;font-weight:lighter;font-style:italic;color:gray;"><br /><a rel="nofollow"><span style="font-size:x-small;font-style:italic;">Get the MATLAB code <noscript>(requires JavaScript)</noscript></span></a><br /><br /> Published with MATLAB&reg; 7.9<br /></p>
</div>
<img src="http://feeds.feedburner.com/~r/SteveOnImageProcessing/~4/WZp6uTnfaHk" height="1" width="1"/>]]></content:encoded>
         <category>Uncategorized</category>
      </item>
      <item>
         <title>Basics: Volume visualization: 4/9 Display of contourslice and isosurface</title>
         <link>http://feedproxy.google.com/~r/DougsMatlabVideoTutorials/~3/4LF6JFJmRPE/</link>
         <description>This short video is the fourth of a series of nine that talks about volume visualization. Patrick gave this talk internally to help technical support engineers understand capabilities of MATLAB for volume visualization. I like his slow, clear, methodical presentation with great visualizations. It is the first time I have deeply understood some of the volume [...]</description>
         <guid isPermaLink="false">http://blogs.mathworks.com/videos/2009/11/11/basics-volume-visualization-49-display-of-contourslice-and-isosurface/</guid>
         <pubDate>Wed, 11 Nov 2009 06:55:37 -0800</pubDate>
         <content:encoded><![CDATA[This short video is the fourth of a series of nine that talks about volume visualization. Patrick gave this talk internally to help technical support engineers understand capabilities of MATLAB for volume visualization.
<p>
<p>
I like his slow, clear, methodical presentation with great visualizations. It is the first time I have deeply understood some of the volume visualization techniques we have. <p>
<ul> <li><a rel="nofollow" target="_blank" href="http://blogs.mathworks.com/videos/2009/10/23/basics-volume-visualization-19-defining-scalar-and-vector-fields/">1 of 9 Definitions for scalar and vector fields. </a></li> <li><a rel="nofollow" target="_blank" href="http://blogs.mathworks.com/videos/2009/10/30/basics-volume-visualization-29-examples-of-scalar-and-vector-fields/">2 of 9 Examples of scalar and vector fields (temperature in a room vs air currents) </a></li> <li><a rel="nofollow" target="_blank" href="http://blogs.mathworks.com/videos/2009/11/06/basics-volume-visualization-39-display-of-scatter3-and-slice-plots/">3 of 9 Displays scatter3 and slice plots. </a></li> <li>4 of 9 Displays contourslice and isosurface. </li>
</ul> <div class="video" style="width:660;height:410;">   <div id="videoalternate168" style="width:660px;height:410px;"> <a rel="nofollow" target="_blank" href="http://www.adobe.com/go/getflashplayer"> <img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player"/> </a> </div> </div>
<img src="http://feeds.feedburner.com/~r/DougsMatlabVideoTutorials/~4/4LF6JFJmRPE" height="1" width="1"/>]]></content:encoded>
      </item>
      <item>
         <title>Writing TIFF files with given width and resolution</title>
         <link>http://feedproxy.google.com/~r/SteveOnImageProcessing/~3/lE35Ziosde0/</link>
         <description>I received the following question recently: I'd like to be able to establish an image size that will be recognized by PDFLATEX when I compile my document. Often, I size an image in MATLAB only to have it occupy more than a [...]</description>
         <guid isPermaLink="false">http://blogs.mathworks.com/steve/2009/11/09/writing-tiff-files-with-given-width-and-resolution/</guid>
         <pubDate>Mon, 09 Nov 2009 07:35:10 -0800</pubDate>
         <content:encoded><![CDATA[<div class="content"><p>I received the following question recently:</p> <p><i>I'd like to be able to establish an image size that will be recognized by PDFLATEX when I compile my document. Often, I size an image in MATLAB only to have it occupy more than a page after compiling in PDFLATEX. I know I can use imresize, but I'd like to resize a PNG so that it is exact 2 inches wide, so I can get some consistency of sizing in my document.</i></p> <p>It occurred to me that this is a common use case in publishing articles, books, etc: "I need this image to print exactly 3 inches wide in my document so it fits nicely in the column." The document might be LaTeX as above, or a Word file, or something else. </p> <p>In publishing, TIFF is usually the format of choice. The MATLAB function <tt>imwrite</tt> can include extra information in the TIFF file to control how wide an image will be printed when included in a document application. This extra information is provided in the form of the <tt>'Resolution'</tt> parameter, which gives pixels per inch. (In this context the term dots per inch is also used.) </p> <p>I wrote about how to use the <tt>'Resolution'</tt> parameter <a rel="nofollow" target="_blank" href="http://blogs.mathworks.com/steve/2006/03/03/help-my-publisher-wants-a-300-dpi-tiff/">way back in 2006</a>, but at the time I didn't explain how to achieve a certain desired printed width. </p> <p>When publishers specify a certain resolution in pixels per inch (dots per inch), <i>and</i> the image should be printed at a certain width, then generally the image has to be resized to meet both criteria. That is, the number of image pixels may have to be changed. </p> <p>To help users prepare such image files I wrote the MATLAB function <a rel="nofollow" target="_blank" href="http://www.mathworks.com/matlabcentral/fileexchange/25595-imwritesize-write-image-file-with-specified-width-and-resolution"><tt>imwritesize</tt></a>, which you can find on the <a rel="nofollow" target="_blank" href="http://www.mathworks.com/matlabcentral/fileexchange/25595-imwritesize-write-image-file-with-specified-width-and-resolution">MATLAB Central File Exchange</a>. </p> <p>In the most simple usage, <tt>imwritesize</tt> will create a TIFF file or PNG file for you so that the image will have the desired width in a document application. </p><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);">rgb = imread(<span style="color:#A020F0;">'peppers.png'</span>);
size(rgb)</pre><pre style="font-style:oblique;">
ans = 384 512 3 </pre><p>Notice the original image has 512 pixels per row.</p> <p>Now write the image out using <tt>imwritesize</tt>: </p><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);">imwritesize(rgb, <span style="color:#A020F0;">'peppers_3in.tif'</span>, 3);</pre><p>The extension of the output filename determines the image file format. To write out a PNG file instead of TIFF, just use the extension '.png'. </p><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);">imwritesize(rgb, <span style="color:#A020F0;">'peppers_3in.png'</span>, 3);</pre><p>With this usage, the number of pixels in the image is not changed. <tt>imwritesize</tt> just saves the image into the file with the right resolution parameter to achieve the desired width; </p><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);">info = imfinfo(<span style="color:#A020F0;">'peppers_3in.tif'</span>);
image_pixels_per_row = info.Width</pre><pre style="font-style:oblique;">
image_pixels_per_row = 512 </pre><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);">document_width_in_inches = image_pixels_per_row / info.XResolution</pre><pre style="font-style:oblique;">
document_width_in_inches = 2.994152046783626 </pre><p>The width is not exactly 3 inches because the resolution value in a TIFF file is restricted to be an integer number of pixels per inch. </p> <p>Now suppose you want the document width of the image to be 3 inches <b>and</b> the document image resolution to be 300 dpi? Then you specify 300 as an additional argument to <tt>imwritesize</tt>: </p><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);">imwritesize(rgb, <span style="color:#A020F0;">'peppers_3in_at_300dpi.tif'</span>, 3, 300);</pre><p>With this usage, the number of image pixels is changed by calling <a rel="nofollow" target="_blank" href="http://www.mathworks.com/access/helpdesk/help/toolbox/images/imresize.html"><tt>imresize</tt></a>, an Image Processing Toolbox function. </p><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);">info2 = imfinfo(<span style="color:#A020F0;">'peppers_3in_at_300dpi.tif'</span>);
image_pixels_per_row = info2.Width</pre><pre style="font-style:oblique;">
image_pixels_per_row = 900 </pre><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);">document_width_in_inches = image_pixels_per_row / info2.XResolution</pre><pre style="font-style:oblique;">
document_width_in_inches = 3 </pre><p>I apologize to those of you living in metric land. I wanted to keep the interface simple so I did not include units options. You could perform a metric conversion in the call to <tt>imwritesize</tt>, like this: </p><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);">imwritesize(rgb, <span style="color:#A020F0;">'peppers_7cm.tif'</span>, 7/2.54)</pre><p>Or you can modify the code in <tt>imwritesize</tt> to suit yourself. I tried to keep the code very straightforward so that users could learn from it. </p> <p>I hope you find this MATLAB Central File Exchange contribution useful. If you want to use this function and you already have MATLAB R2009b, you should consider taking this chance to experiment with the new <a rel="nofollow" target="_blank" href="http://blogs.mathworks.com/desktop/2009/09/21/the-front-page-of-the-file-exchange-your-desktop/">MATLAB Desktop / File Exchange integration</a>. </p><p style="text-align:right;font-size:xx-small;font-weight:lighter;font-style:italic;color:gray;"><br /><a rel="nofollow"><span style="font-size:x-small;font-style:italic;">Get the MATLAB code <noscript>(requires JavaScript)</noscript></span></a><br /><br /> Published with MATLAB&reg; 7.9<br /></p>
</div>
<img src="http://feeds.feedburner.com/~r/SteveOnImageProcessing/~4/lE35Ziosde0" height="1" width="1"/>]]></content:encoded>
         <category>Uncategorized</category>
      </item>
      <item>
         <title>The redesigned Plot Selector in R2009b</title>
         <link>http://feedproxy.google.com/~r/mathworks/desktop/~3/17lKzDbBFhI/</link>
         <description>The Plot Selector has been redesigned in R2009b! The user interface takes cues from the Function Browser with a search field at the top of the tool and the ability to &amp;#8220;tear off&amp;#8221; the window to keep it visible. We&amp;#8217;ve tried very hard to reuse the same concepts in the user interface when it makes [...]</description>
         <guid isPermaLink="false">http://blogs.mathworks.com/desktop/2009/11/09/the-redesigned-plot-selector-in-r2009b/</guid>
         <pubDate>Mon, 09 Nov 2009 04:29:03 -0800</pubDate>
         <content:encoded><![CDATA[<p>The <a rel="nofollow" target="_blank" href="http://www.mathworks.com/access/helpdesk/help/techdoc/index.html?/access/helpdesk/help/techdoc/rn/br5ktrh-1.html#br5ktri-15">Plot Selector</a> has been redesigned in R2009b! The user interface takes cues from the Function Browser with a search field at the top of the tool and the ability to &#8220;tear off&#8221; the window to keep it visible. We&#8217;ve tried very hard to reuse the same concepts in the user interface when it makes sense (e.g. the search field). This makes it easier for you to apply concepts from one tool in another tool, and keeps the overall look of the product consistent.</p>
<div align="center">
<a rel="nofollow" target="_blank" href="http://blogs.mathworks.com/images/desktop/ken_orr_plot_selector/plot_selector.png"><img border="0" src="http://blogs.mathworks.com/images/desktop/ken_orr_plot_selector/plot_selector_small.png"></a>
</div>
<p>The Plot Selector is available via the &nbsp;<img border="0" src="http://blogs.mathworks.com/images/desktop/ken_orr_plot_selector/browse_plots.png">&nbsp; button in the Workspace Browser.</p>
<div align="center">
<img border="0" src="http://blogs.mathworks.com/images/desktop/ken_orr_plot_selector/workspace.png">
</div>
<p>One of our overall goals with user interface design in MATLAB is to help you stay focused on what your doing. To do this, we need to offer you the right information at the right time. In the Plot Selector, this means showing you a graphic of what the plot might look like, as well as more detailed information about the what each plot does. We also show you details about a plot when you hover over it in the Plot Selector, which helps keep you &#8220;in flow&#8221;:</p>
<div align="center">
<a rel="nofollow" target="_blank" href="http://blogs.mathworks.com/images/desktop/ken_orr_plot_selector/plot_selector_popup.png"><img border="0" src="http://blogs.mathworks.com/images/desktop/ken_orr_plot_selector/plot_selector_popup_small.png"></a>
</div>
<p>We also wanted to help streamline your workflow. If there are plots that you frequently use with a particular type of data, you can select the &nbsp;<img border="0" src="http://blogs.mathworks.com/images/desktop/ken_orr_plot_selector/star_on_button.png">&nbsp; button and promote that plot to the &#8220;Favorites&#8221; section, which appears at the top of the Plot Selector.</p>
<p>Finally, the Plot Selector now integrates with toolboxes. So if there is a plot that applies to your selected data, it will show up in the Plot Selector. For example, my Plot Selector shows plots from the Statistics Toolbox, because I have that toolbox installed:</p>
<div align="center">
<a rel="nofollow" target="_blank" href="http://blogs.mathworks.com/images/desktop/ken_orr_plot_selector/plot_selector_stats.png"><img border="0" src="http://blogs.mathworks.com/images/desktop/ken_orr_plot_selector/plot_selector_stats_small.png"></a>
</div>
<p>We think this redesign will make it easier for you to plot your data and help keep you focused on the task at hand. What do you think?</p>
<img src="http://feeds.feedburner.com/~r/mathworks/desktop/~4/17lKzDbBFhI" height="1" width="1"/>]]></content:encoded>
         <category>Data Tools</category>
      </item>
      <item>
         <title>Basics: Volume visualization: 3/9 Display of scatter3 and slice plots</title>
         <link>http://feedproxy.google.com/~r/DougsMatlabVideoTutorials/~3/kOmKcWl8NhE/</link>
         <description>This short video is the third of a series of nine that talks about volume visualization. Patrick gave this talk internally to help technical support engineers understand capabilities of MATLAB for volume visualization. I like his slow, clear, methodical presentation with great visualizations. It is the first time I have deeply understood some of the volume [...]</description>
         <guid isPermaLink="false">http://blogs.mathworks.com/videos/2009/11/06/basics-volume-visualization-39-display-of-scatter3-and-slice-plots/</guid>
         <pubDate>Fri, 06 Nov 2009 07:05:39 -0800</pubDate>
         <content:encoded><![CDATA[This short video is the third of a series of nine that talks about volume visualization. Patrick gave this talk internally to help technical support engineers understand capabilities of MATLAB for volume visualization.
<p>
<p>
I like his slow, clear, methodical presentation with great visualizations. It is the first time I have deeply understood some of the volume visualization techniques we have. <p>
<ul> <li><a rel="nofollow" target="_blank" href="http://blogs.mathworks.com/videos/2009/10/23/basics-volume-visualization-19-defining-scalar-and-vector-fields/">1 of 9 Definitions for scalar and vector fields. </a></li> <li><a rel="nofollow" target="_blank" href="http://blogs.mathworks.com/videos/2009/10/30/basics-volume-visualization-29-examples-of-scalar-and-vector-fields/">2 of 9 Examples of scalar and vector fields (temperature in a room vs air currents) </a></li> <li>3 of 9 Displays scatter3 and slice plots. </li>
</ul> <div class="video" style="width:660;height:410;">   <div id="videoalternate167" style="width:660px;height:410px;"> <a rel="nofollow" target="_blank" href="http://www.adobe.com/go/getflashplayer"> <img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player"/> </a> </div> </div>
<img src="http://feeds.feedburner.com/~r/DougsMatlabVideoTutorials/~4/kOmKcWl8NhE" height="1" width="1"/>]]></content:encoded>
      </item>
      <item>
         <title>Segmenting Coins…a Tutorial on Blob Analysis</title>
         <link>http://feedproxy.google.com/~r/mathworks/pick/~3/Is0CxozWfrI/</link>
         <description>Many of us who have used or participated in comp.soft-sys.matlab over the years--particularly those of us who have had occasion to solve image processing problems--have come to appreciate Image Analyst's thoughts on relevant matters. Recently, Image Analyst had occasion [...]</description>
         <guid isPermaLink="false">http://blogs.mathworks.com/pick/2009/11/06/segmenting-coinsa-tutorial-on-blob-analysis/</guid>
         <pubDate>Fri, 06 Nov 2009 05:58:14 -0800</pubDate>
         <content:encoded><![CDATA[<div class="content"><p>Many of us who have used or participated in <a rel="nofollow" target="_blank" href="http://www.mathworks.com/matlabcentral/newsreader/">comp.soft-sys.matlab</a> over the years--particularly those of us who have had occasion to solve image processing problems--have come to appreciate <a rel="nofollow" target="_blank" href="http://www.mathworks.com/matlabcentral/fileexchange/authors/31862">Image Analyst</a>'s thoughts on relevant matters. </p> <p>Recently, Image Analyst had occasion to share his first file through the File Exchange--a <a rel="nofollow" target="_blank" href="http://www.mathworks.com/matlabcentral/fileexchange/25157">demo tutorial on blob analysis</a>. In a nice, well-documented bit of code, IA steps us through an approach to segmenting, and determining the properties of, some objects in an image. In this case, the image is a sample ('coins.png') that ships with the <a rel="nofollow" target="_blank" href="http://www.mathworks.com/products/image/">Image Processing Toolbox</a>. </p> <p>IA's code shows how one might segment objects of interest (coins) from the background, then use <a rel="nofollow" target="_blank" href="http://www.mathworks.com/access/helpdesk/help/toolbox/images/regionprops.html"><tt>regionprops</tt></a> (my favorite IPT function!) to differentiate nickels from dimes, and dull dimes from shiny ones: </p> <p><img vspace="5" hspace="5" src="http://blogs.mathworks.com/pick/../images/pick/blobsdemo.png"> </p> <p>This is a nice demo--very informative, and certainly worth a read. Two thoughts: 1) IA's code uses <a rel="nofollow" target="_blank" href="http://www.mathworks.com/access/helpdesk/help/toolbox/images/bwlabel.html"><tt>bwlabel</tt></a> to calculate a connected components matrix of the image as a precursor to calling <tt>regionprops</tt>. As of R2009a, the new IPT function <a rel="nofollow" target="_blank" href="http://www.mathworks.com/access/helpdesk/help/toolbox/images/bwconncomp.html"><tt>bwconncomp</tt></a> replaces <tt>bwlabel</tt> as the preferred approach; it uses significantly less memory, and can be markedly faster! Also, 2) IA shows how one can extract the specific pixels (PixelIdxList) associated with each object of interest, then calculate statistics on those pixel intensities to differentiate shiny from dull objects. Note that the fourth syntax of <tt>regionprops</tt> in the documentation enables one to avoid this step, and instead to operate directly on the original intensity image. Using this syntax, one can calculate directly the MIN, MAX, or MEAN intensitities--or even the weighted centroids-- of each blob in the image. </p> <p>Nice work, Image Analyst!</p> <p><a rel="nofollow" target="_blank" href="http://blogs.mathworks.com/pick/?p=2493#respond">Comments?</a></p><p style="text-align:right;font-size:xx-small;font-weight:lighter;font-style:italic;color:gray;"><br /><a rel="nofollow"><span style="font-size:x-small;font-style:italic;">Get the MATLAB code <noscript>(requires JavaScript)</noscript></span></a><br /><br /> Published with MATLAB&reg; 7.9<br /></p>
</div>
<img src="http://feeds.feedburner.com/~r/mathworks/pick/~4/Is0CxozWfrI" height="1" width="1"/>]]></content:encoded>
         <category>Picks</category>
      </item>
      <item>
         <title>Generated Code for Variable Size Signals</title>
         <link>http://feedproxy.google.com/~r/SethOnSimulink/~3/Yf71tJ0eEkk/</link>
         <description>Aarti recently posted about Variable Size Signals in Simulink. Han responded with this comment: Aarti, I would be interested in the effect on RTW generated code for variable size signals. Could you show some examples? -Han Here is Aarti's response. Hi Han, Thank you for your comment. In the case of a variable size signal, the generated code allocates the [...]</description>
         <guid isPermaLink="false">http://blogs.mathworks.com/seth/2009/11/06/generated-code-for-variable-size-signals/</guid>
         <pubDate>Thu, 05 Nov 2009 17:48:56 -0800</pubDate>
         <content:encoded><![CDATA[<p>Aarti recently posted about <a rel="nofollow" target="_blank" href="http://blogs.mathworks.com/seth/2009/10/16/radar-tracking-in-simulink-variable-size-signals/">Variable Size Signals</a> in Simulink. Han responded with <a rel="nofollow" target="_blank" href="http://blogs.mathworks.com/seth/2009/10/16/radar-tracking-in-simulink-variable-size-signals/#comments">this comment</a>:</p> <blockquote>
Aarti,<br /> I would be interested in the effect on RTW generated code for variable size signals. Could you show some examples?<br /> -Han<br />
</blockquote> <p>Here is Aarti's response.</p> <p><img src="http://blogs.mathworks.com/images/seth/2009Q4/Aarti_Ramani.jpg" alt="Aarti Ramani"></p> <p>Hi Han,</p> <p>Thank you for your comment. In the case of a variable size signal, the generated code allocates the maximum possible size for the input/output variables. </p> <p>This allows signal sizes to vary during execution (as opposed to being hard-coded after model compilation). The generated code also propagates signal sizes through the model and accordingly assign the required dimension to signals. The algorithm code only needs to operate on the portion of memory required (thus saving execution time).</p> <p>The following model uses the Switch Block to change the size of its output signal.</p> <p><img src="http://blogs.mathworks.com/images/seth/2009Q4/varDim_SwitchGain.png" alt="Simulink model containing a Switch and Gain block that handles variable size signals."/></p> <p>The generated code looks like this:</p> <p><pre><code style="font-size:11pt;"> /* Switch: ' /Switch' incorporates: * Inport: ' /In1' * Inport: ' /In2' * Inport: ' /In3' */ if (In2 &gt;= 0.0) { model_XDim = 1; X[0] = In1; } else { model_XDim = 5; for (tmp = 0; tmp &lt; 5; tmp++) { X[tmp] = In3[tmp]; } } /* Gain: ' /Gain' */ model_YDim = model_XDim; loop_ub = model_XDim - 1; for (tmp = 0; tmp &lt;= loop_ub; tmp++) { Y[tmp] = 2.0 * X[tmp]; }
</code></pre></p> <p>In the generated code, notice how the variable <em>model_Xdim</em> has the lower and upper bound pre-allocated as 1 and 5, 5 being the width of the 3rd Inport block. Using these values, the <em>loop_ub</em> variable for the Switch block is calculated. </p> <p>Thanks!</p> <p>Aarti</p> <p>Is this the code you expected? Leave a <a rel="nofollow" target="_blank" href="http://blogs.mathworks.com/seth/?p=73&#comment">comment here</a> and tell me about it.</p><img src="http://feeds.feedburner.com/~r/SethOnSimulink/~4/Yf71tJ0eEkk" height="1" width="1"/>]]></content:encoded>
      </item>
      <item>
         <title>Calculus with Empty Arrays</title>
         <link>http://feedproxy.google.com/~r/mathworks/loren/~3/3OCpt7t-shs/</link>
         <description>MATLAB has had empty arrays since before I started using the program. When I started, the only size empty array was 0x0. When version 5 was released, empty arrays came along for the N-dimensional ride and got more shapely. [...]</description>
         <guid isPermaLink="false">http://blogs.mathworks.com/loren/2009/11/04/calculus-with-empty-arrays/</guid>
         <pubDate>Wed, 04 Nov 2009 11:30:53 -0800</pubDate>
         <content:encoded><![CDATA[<div class="content"><p>MATLAB has had empty arrays since before I started using the program. When I started, the only size empty array was <tt>0x0</tt>. When version 5 was released, empty arrays came along for the N-dimensional ride and got more shapely. </p>  <h3>Contents</h3> <div> <ul> <li><a rel="nofollow" href="#2">From the Newsgroup</a></li> <li><a rel="nofollow" href="#4">Dimensions Matter in MATLAB</a></li> <li><a rel="nofollow" href="#11">Empty Array Shapes</a></li> <li><a rel="nofollow" href="#12">Reference</a></li> <li><a rel="nofollow" href="#13">Got an Empty Question?</a></li> </ul> </div> <p>Even relatively simple expressions involving empty arrays cause confusion from time to time, especially in concert with other rules in MATLAB (such as <tt>NaN</tt> values usually propagate from inputs to outputs). Let's play around a little with some empty arrays to get some insight. </p> <h3>From the Newsgroup<a rel="nofollow" name="2"></a></h3> <p>This <a rel="nofollow" target="_blank" href="http://www.mathworks.com/matlabcentral/newsreader/view_thread/263290#687525">post</a> on the MATLAB newsgroup motivated me to talk about empty arrays. Here's is an excerpt from the original post: </p><pre> I knew that Nan+4 = NaN, but why is []+4 = [] ? Is there more 'black hole behaviour' I should know about?</pre><h3>Dimensions Matter in MATLAB<a rel="nofollow" name="4"></a></h3> <p>Dimensions matter in MATLAB and you will get error messages when dimensions don't agree. Early on, we found it was convenient to treat scalars as an exception with operators (e.g., <tt><b>,.</b></tt>) and to treat them as if they were expanded to the size of the other operand. So </p><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);">rand(3,3) + pi</pre><pre style="font-style:oblique;">ans = 4.10648118878907 4.09875960183274 3.28347899221701 3.29920573526734 3.62696830231263 3.56335393621607 4.11218543535041 3.94187312247859 4.05732817877886
</pre><p>adds the value <tt>pi</tt> to the random <tt>3x3</tt> just created. It's as if a <tt>3x3</tt> constant array filled with the value <tt>pi</tt> was created and added elementwise to the other array. </p> <p>So what does that mean for an empty operand? Its size has at least one 0 value. So MATLAB expands <tt>pi</tt> in this expression <tt>[] + pi</tt> to be the same size as <tt>[]</tt> (which happens to be <tt>0x0</tt> here). When that happens, MATLAB creates a second empty array, and then adds the two empty arrays. Hence we get </p><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);">[] + pi</pre><pre style="font-style:oblique;">ans = []
</pre><p>returing an empty output.</p> <p>MATLAB applies the scalar expansion rule to operators. So, for example, <i>size(anything+scalar)</i> is <i>size(anything)</i>. As a logical but sometimes surprising consequence, empty arrays often (but not always) propagate through calculations. When doesn't that happen? With some functions where mathematically logical analysis demands different results. </p><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);">sum([])</pre><pre style="font-style:oblique;">ans = 0
</pre><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);">prod([])</pre><pre style="font-style:oblique;">ans = 1
</pre><p>So, why is the sum zero and the product 1? Because they are the identity elements (as in group theory) for sum and product respectively. Think about how to start the computation for a sum or a product and how you would initialize the first value. That's the value given before adding or multiplying any of the array elements, hence the values 0 and 1 respectively. </p> <h3>Empty Array Shapes<a rel="nofollow" name="11"></a></h3> <p>Empty arrays can be N-dimensional, and don't need all dimensions to be 0. However, they still must obey the rules about dimensions needing to agree. There are consequences that may surprise you, but they do follow logically. Here's an example of trying to add two empty arrays, ending up in an error! </p><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);">a = zeros(0,1)
b = zeros(1,0)
<span style="color:#0000FF;">try</span> a+b
<span style="color:#0000FF;">catch</span> MEplus fprintf(<span style="color:#A020F0;">'&#92;n'</span>) disp(MEplus.message)
<span style="color:#0000FF;">end</span></pre><pre style="font-style:oblique;">a = Empty matrix: 0-by-1
b = Empty matrix: 1-by-0 Matrix dimensions must agree.
</pre><h3>Reference<a rel="nofollow" name="12"></a></h3> <p>For more information about empty arrays, check out <a rel="nofollow" target="_blank" href="http://www.mathworks.com/access/helpdesk/help/techdoc/math/f1-86359.html#f1-86384">this page</a> in the documentation. </p> <h3>Got an Empty Question?<a rel="nofollow" name="13"></a></h3> <p>Got any empty questions (really, questions about empty!)? Or comments? Post them <a rel="nofollow" target="_blank" href="http://blogs.mathworks.com/loren/?p=204#respond">here</a>. </p><p style="text-align:right;font-size:xx-small;font-weight:lighter;font-style:italic;color:gray;"><br /><a rel="nofollow"><span style="font-size:x-small;font-style:italic;">Get the MATLAB code <noscript>(requires JavaScript)</noscript></span></a><br /><br /> Published with MATLAB&reg; 7.9<br /></p>
</div>
<img src="http://feeds.feedburner.com/~r/mathworks/loren/~4/3OCpt7t-shs" height="1" width="1"/>]]></content:encoded>
      </item>
      <item>
         <title>Contest: Flooding</title>
         <link>http://feedproxy.google.com/~r/DougsMatlabVideoTutorials/~3/nI8gtDnmks8/</link>
         <description>The 20th MATLAB programming contest just went live! Get all the information here. Our more faithful blog readers might have a head start on this puzzle&amp;#8230; Finding four connected regions. A puzzler about the game that inspired this contest. Winning entries to the above puzzler.</description>
         <guid isPermaLink="false">http://blogs.mathworks.com/videos/2009/11/04/contest-flooding/</guid>
         <pubDate>Wed, 04 Nov 2009 09:05:33 -0800</pubDate>
         <content:encoded><![CDATA[The 20th MATLAB programming contest just went live!
<p>
<a rel="nofollow" target="_blank" href="http://www.flickr.com/photos/dey/100611750/"><img src='http://blogs.mathworks.com/videos/../images/videos/2009/11/colors1.jpg' alt='colors1.jpg'/></a>
<p>
<a rel="nofollow" target="_blank" href="http://www.mathworks.com/contest/flooding/rules.html">Get all the information here. </a>
<p>
Our more faithful blog readers might have a head start on this puzzle&#8230;
<p>
<a rel="nofollow" target="_blank" href="http://blogs.mathworks.com/videos/2009/06/17/puzzler-find-four-connected-component-to-element-1-of-2-d-matrix/">Finding four connected regions.</a>
<p>
<a rel="nofollow" target="_blank" href="http://blogs.mathworks.com/videos/2009/07/28/puzzler-rules-of-the-new-game/">A puzzler about the game that inspired this contest.</a>
<p>
<a rel="nofollow" target="_blank" href="http://blogs.mathworks.com/videos/2009/08/14/puzzler-results-of-most-difficult-puzzler-yet/">Winning entries to the above puzzler.</a><img src="http://feeds.feedburner.com/~r/DougsMatlabVideoTutorials/~4/nI8gtDnmks8" height="1" width="1"/>]]></content:encoded>
         <category>Topic: Puzzler</category>
      </item>
      <item>
         <title>The conv function and implementation tradeoffs</title>
         <link>http://feedproxy.google.com/~r/SteveOnImageProcessing/~3/Snab-x9cEHk/</link>
         <description>A friend from my grad school days (back in the previous millenium) is an electrical engineering professor. Students in his class recently asked him why the conv function is not implemented using FFTs. I'm not on the team responsible for conv, [...]</description>
         <guid isPermaLink="false">http://blogs.mathworks.com/steve/2009/11/03/the-conv-function-and-implementation-tradeoffs/</guid>
         <pubDate>Tue, 03 Nov 2009 06:56:58 -0800</pubDate>
         <content:encoded><![CDATA[<div class="content"><p>A friend from my grad school days (back in the previous millenium) is an electrical engineering professor. Students in his class recently asked him why the <tt>conv</tt> function is not implemented using FFTs. </p> <p>I'm not on the team responsible for <tt>conv</tt>, but I wrote back with my thoughts, and I thought I would share them here as well. </p> <p>Let's review the basics. Using the typical convolution formula to compute the one-dimensional convolution of a P-element sequence A with Q-element sequence B has a computational complexity of <img vspace="5" hspace="5" src="http://blogs.mathworks.com/images/steve/2009/fft_based_conv_eq04674.png"> . However, the discrete Fourier transform (DFT) can be used to implement convolution as follows: </p> <p>1. Compute the L-point DFT of A, where <img vspace="5" hspace="5" src="http://blogs.mathworks.com/images/steve/2009/fft_based_conv_eq40865.png"> . </p> <p>2. Compute the L-point DFT of B.</p> <p>3. Multiply the two DFTs.</p> <p>4. Compute the inverse DFT to get the convolution.</p> <p>Here's a simple MATLAB function for computing convolution using the Fast Fourier Transform (FFT), which is simply a fast algorithm for computing the DFT. </p><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);">type <span style="color:#A020F0;">conv_fft</span></pre><pre style="font-style:oblique;">
function c = conv_fft(a, b) P = numel(a);
Q = numel(b);
L = P + Q - 1;
K = 2^nextpow2(L); c = ifft(fft(a, K) .* fft(b, K));
c = c(1:L); </pre><p>Note that the code uses the next power-of-two greater than or equal to L, although this is not strictly necessary. The <tt>fft</tt> function operates in <img vspace="5" hspace="5" src="http://blogs.mathworks.com/images/steve/2009/fft_based_conv_eq00311.png"> time whether or not L is a power of two. </p> <p>The overall computational complexity of these steps is <img vspace="5" hspace="5" src="http://blogs.mathworks.com/images/steve/2009/fft_based_conv_eq47887.png"> . For P and Q sufficiently large, then, using the DFT to implement convolution is a computational win. </p> <p>So why don't we do it?</p> <p>There are several technical factors. Let's look at speed, exact computation, and memory.</p> <p><b>Speed</b></p> <p>One factor is that DFT-based computation is not <b>always</b> faster. Let's do an experiment where we compute the convolution of a 1000-element sequence with another sequence of varying length. (Get the <tt>timeit</tt> function from the <a rel="nofollow" target="_blank" href="http://www.mathworks.com/matlabcentral/fileexchange/18798-timeit-benchmarking-function">MATLAB Central File Exchange</a>.) </p><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);">x = rand(1, 1000);
nn = 25:25:1000; t_normal = zeros(size(nn));
t_fft = zeros(size(nn)); <span style="color:#0000FF;">for</span> k = 1:numel(nn) n = nn(k); y = rand(1, n); t_normal(k) = timeit(@() conv(x, y)); t_fft(k) = timeit(@() conv_fft(x, y));
<span style="color:#0000FF;">end</span></pre><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);">plot(nn, t_normal, nn, t_fft)
legend({<span style="color:#A020F0;">'Normal computation'</span>, <span style="color:#A020F0;">'FFT-based computation'</span>})</pre><img vspace="5" hspace="5" src="http://blogs.mathworks.com/images/steve/2009/fft_based_conv_01.png"> <p>For sequences <tt>y</tt> shorter than a certain length, called the <i>cross-over point</i>, it's quicker to use the normal computation. </p> <p><b>Exact computation</b></p> <p>A second consideration is whether the computation is subject to floating-point round-off errors and to what degree. There are applications, for example, where the convolution of integer-valued sequences is computed. For such applications, a user would reasonably expect the output sequence to be integer-valued as well. </p> <p>To illustrate, here's a simple function that computes <a rel="nofollow" target="_blank" href="http://en.wikipedia.org/wiki/Binomial_coefficient">n-th order binomial coefficients</a> using convolution: </p><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);">type <span style="color:#A020F0;">binom</span></pre><pre style="font-style:oblique;">
function c = binom(n) c = 1;
for k = 1:n c = conv(c, [1 1]);
end </pre><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);">binom(7)</pre><pre style="font-style:oblique;">
ans = 1 7 21 35 35 21 7 1 </pre><p>I wrote a variation called <tt>binom_fft</tt> that is the same as <tt>binom</tt> except that it calls <tt>conv_fft</tt>. </p><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);">format <span style="color:#A020F0;">long</span>
binom_fft(7)</pre><pre style="font-style:oblique;">
ans = Columns 1 through 4 1.000000000000000 6.999999999999998 21.000000000000000 35.000000000000000 Columns 5 through 8 35.000000000000000 21.000000000000000 7.000000000000000 0.999999999999996 </pre><p>Whoops! What's going on? The answer is that the FFT-based implementation of convolution is subject to floating-point round-off error. </p> <p>I imagine that most MATLAB users would consider the output of <tt>binom_fft</tt> to be <b>wrong</b>. </p> <p><b>Memory</b></p> <p>The last technical consideration I want to mention is memory. Because of the padding and complex arithmetic involved in the FFT computations, the FFT-based convolution implementation requires a lot more memory than the normal computation. This may not often be a problem for one-dimensional computations, but it can be a big deal for multidimensional computations. </p> <p><b>Final thoughts</b></p> <p>The technical considerations listed above can all be solved in principle. The implementation could switch to using the normal method for short or integer-valued sequences, for example. And there are FFT-based techniques such as <a rel="nofollow" target="_blank" href="http://en.wikipedia.org/wiki/Overlap-add_method">overlap-and-add</a> to reduce the memory load. </p> <p>But the problem can get quite complicated. Testing floating-point values to see if they are integers, for example, can be slow. Also, I suspect (but have not checked) that a multithreaded implemention of the normal computation will take advantage of multiple cores better than a multithreaded FFT-based method. That would change the cross-over point between the two methods. And the exact cross-over point will vary from computer to computer, making it likely that our implementation would be somewhat slower for some people for some problems. </p> <p>Overall, my inclination would be to provide FFT-based convolution as a separate function rather than reimplementing <tt>conv</tt>. And that's what we've done. See the function <a rel="nofollow" target="_blank" href="http://www.mathworks.com/access/helpdesk/help/toolbox/signal/fftfilt.html"><tt>fftfilt</tt></a> in the Signal Processing Toolbox. </p> <p>Do you disagree with this approach? Post your comment.</p><p style="text-align:right;font-size:xx-small;font-weight:lighter;font-style:italic;color:gray;"><br /><a rel="nofollow"><span style="font-size:x-small;font-style:italic;">Get the MATLAB code <noscript>(requires JavaScript)</noscript></span></a><br /><br /> Published with MATLAB&reg; 7.9<br /></p>
</div>
<img src="http://feeds.feedburner.com/~r/SteveOnImageProcessing/~4/Snab-x9cEHk" height="1" width="1"/>]]></content:encoded>
         <category>Uncategorized</category>
      </item>
      <item>
         <title>Puzzler: Ultimate Frisbee- call it! Wrap up</title>
         <link>http://feedproxy.google.com/~r/DougsMatlabVideoTutorials/~3/wkePmJPUsxE/</link>
         <description>I do not know why I am still always amazed at the many different ways that simple problems are solved by different people. To end the suspense for everyone playing along at home, &amp;#8220;For two coins (i.e. Frisbees®) that have the same probability of being heads or tails (but not necessarily fair coins) you [...]</description>
         <guid isPermaLink="false">http://blogs.mathworks.com/videos/2009/11/03/puzzler-ultimate-frisbee-call-it-wrap-up/</guid>
         <pubDate>Tue, 03 Nov 2009 06:49:03 -0800</pubDate>
         <content:encoded><![CDATA[I do not know why I am still always amazed at the many different ways that simple problems are solved by different people. To end the suspense for everyone playing along at home, <p>
<strong>&#8220;For two coins (i.e. Frisbees®) that have the same probability of being heads or tails (but not necessarily fair coins) you are at worst going to win 50% of the time when you choose &#8217;same&#8217;.&#8221;</strong>
<a rel="nofollow" target="_blank" href="http://blogs.mathworks.com/videos/2009/10/27/puzzler-ultimate-frisbee-call-it/">(Here is the original post)</a> <p>
My argument on the Ultimate Frisbee field was <p>
<strong>&#8220;Imagine the two Frisbee come up heads 99% of the time, what do you choose?&#8221; </strong>
<p>
&#8220;Same!&#8221; <p>
<strong>&#8220;What about 98%?&#8221; </strong>
<p>
&#8220;Same&#8221;
<p>
<strong>&#8220;This logic holds all the way through, even to 50.00001. At 50% it just does not matter, so always choose same.&#8221;</strong>
<p> The more rigorous and MATLAB proofs were more along these lines:
<img src='http://blogs.mathworks.com/videos/../images/videos/2009/11/frisbeegui.jpg' alt='frisbeegui.jpg'/> <p>
This was a GUI that you watched as it went through a Monte Carlo simulation. Thanks Richard <p> Arman did a more traditional proof, citing Wikipedia <p>
<pre>
Let p be the probability of having tails.
The probability of having "different" is p(1-p)+(1-p)p.
The probability of having "same" is p^2+(1-p)^2. <a rel="nofollow" target="_blank" href="http://en.wikipedia.org/wiki/Inequality_of_arithmetic_and_geometric_means">From the arithmetic mean geometric mean inequality</a>, we know that p^2+(1-p)^2 &gt;= 2*p(1-p) and equality holds if p=1-p which means p=1/2. Therefore &#8220;same&#8221; is better choice for any p value.
</pre>
<p>
<p>
There were many variations on this plot: <img src='http://blogs.mathworks.com/videos/../images/videos/2009/11/frisbeedifference.jpg' alt='frisbeedifference.jpg'/> <p>
I liked Zane&#8217;s here because it shows how much better off you are with &#8217;same&#8217; for each value of unfairness in the coin.
<p>
<p> Christopher won the challenge by going to the next level, pointing out that you could make these unfair Frisbees almost fair by flipping three and calling for an odd number (1 or 3) vs even number (0 or 2) of heads. <img src='http://blogs.mathworks.com/videos/../images/videos/2009/11/frisbeecombos.jpg' alt='frisbeecombos.jpg'/> <p> Thank you everyone for playing, and finally putting this question to rest! Now the ethical question, knowing the coin flip is unfair, is it in the <a rel="nofollow" target="_blank" href="http://en.wikipedia.org/wiki/Spirit_of_the_Game#Spirit_of_the_game">Spirit of The Game</a> to let the other guy choose? Should we move to Christopher&#8217;s method of flipping three Frisbees? <p>
Frisbee® is a Registered Trademark of © 2004 Wham-o Inc. All Rights Reserved.
<img src="http://feeds.feedburner.com/~r/DougsMatlabVideoTutorials/~4/wkePmJPUsxE" height="1" width="1"/>]]></content:encoded>
      </item>
      <item>
         <title>Help browser search updates</title>
         <link>http://feedproxy.google.com/~r/mathworks/desktop/~3/DdJAr35ePFc/</link>
         <description>Everywhere you look, searching is becoming the standard way of accessing information, and our documentation is no exception. In MATLAB R2009b we&amp;#8217;ve updated the Help browser&amp;#8217;s search functionality to help you find what you&amp;#8217;re looking for more quickly. In this post I&amp;#8217;ll give you a quick tour of the changes.
First, let&amp;#8217;s take a [...]</description>
         <guid isPermaLink="false">http://blogs.mathworks.com/desktop/2009/11/02/help-browser-search-updates/</guid>
         <pubDate>Mon, 02 Nov 2009 06:08:03 -0800</pubDate>
         <content:encoded><![CDATA[<p>Everywhere you look, searching is becoming the standard way of accessing information, and our documentation is no exception. In MATLAB R2009b we&#8217;ve updated the Help browser&#8217;s search functionality to help you find what you&#8217;re looking for more quickly. In this post I&#8217;ll give you a quick tour of the changes.</p>
<p>First, let&#8217;s take a look at the R2009a search results display. Using the default Help browser layout, here are the results of a search for &#8220;fft&#8221; with all MathWorks products installed:</p>
<p><a rel="nofollow" target="_blank" href='http://blogs.mathworks.com/desktop/../images/desktop/fft_9a_doc_results.PNG' title='fft_9a_doc_results.PNG'><img src='http://blogs.mathworks.com/desktop/../images/desktop/fft_9a_doc_results.PNG' alt='fft_9a_doc_results.PNG'/></a></p>
<p>We weren&#8217;t happy that this display does not give you an easy way to differentiate among the top three results. They&#8217;re function reference pages from different products, but you&#8217;d never know it because the Product column is scrolled off the right side of the results area. If you want to see what products the results are in (or sort by product), you need to scroll over and lose sight of the title. There are a few other issues that we fixed, but that&#8217;s the big one.</p>
<p>Now lets see how the same search looks in R2009b:</p>
<p><a rel="nofollow" target="_blank" href='http://blogs.mathworks.com/desktop/../images/desktop/fft_9b_doc_results.PNG' title='fft_9b_doc_results.PNG'><img src='http://blogs.mathworks.com/desktop/../images/desktop/fft_9b_doc_results.PNG' alt='fft_9b_doc_results.PNG'/></a></p>
<p>The first thing you might notice is that each result takes up a lot more vertical space, so you don&#8217;t see as many results. That&#8217;s true, but we think the new features are worth the tradeoff - we&#8217;re going for quality over quantity in the results. Let&#8217;s take a quick look at what we&#8217;ve changed:</p>
<ul>
<li>There&#8217;s no awkward horizontal scrolling in the search results area, ever.</li>
<li>We&#8217;re using an icon to display the type of result - these icons are the same ones that are used in the top level of the new table of contents.</li>
<li>Demo search results are now listed together with the documentation results.</li>
<li>Each result includes some snippets from the result page, which shows the context in which the search term is used.</li>
<li>For reference pages, we&#8217;re including the summary line (for example, in the top result above we&#8217;re displaying &#8220;Discrete Fourier transform&#8221;).</li>
<li>The sorting options have changed.</li>
</ul>
<p>About those sorting options&#8230; In R2009b sorting is all about organizing your search results. Now that we categorize results by type, that was a natural addition to the sort options. We also felt that the old options to sort by title or section didn&#8217;t provide a lot of value, so we removed them. To further emphasize the notion that sorting helps you organize your results, when you sort by type or product we group the results into collapsible sections. That way you can easily show or hide entire groups of results that you find useful or not.</p>
<p>We hope that these new features will help you find what you&#8217;re looking for when you search our documentation. Give them a shot and let us know what you think.</p>
<img src="http://feeds.feedburner.com/~r/mathworks/desktop/~4/DdJAr35ePFc" height="1" width="1"/>]]></content:encoded>
      </item>
      <item>
         <title>Basics: Volume visualization: 2/9 Examples of scalar and vector fields</title>
         <link>http://feedproxy.google.com/~r/DougsMatlabVideoTutorials/~3/3cfrO9Tda2U/</link>
         <description>This short video is the second of a series of nine that talks about volume visualization. Patrick gave this talk internally to help technical support engineers understand capabilities of MATLAB for volume visualization. I like his slow, clear, methodical presentation with great visualizations. It is the first time I have deeply understood some of the volume [...]</description>
         <guid isPermaLink="false">http://blogs.mathworks.com/videos/2009/10/30/basics-volume-visualization-29-examples-of-scalar-and-vector-fields/</guid>
         <pubDate>Fri, 30 Oct 2009 13:44:14 -0700</pubDate>
         <content:encoded><![CDATA[This short video is the second of a series of nine that talks about volume visualization. Patrick gave this talk internally to help technical support engineers understand capabilities of MATLAB for volume visualization.
<p>
<p>
I like his slow, clear, methodical presentation with great visualizations. It is the first time I have deeply understood some of the volume visualization techniques we have. <p>
<ul> <li><a rel="nofollow" target="_blank" href="http://blogs.mathworks.com/videos/2009/10/23/basics-volume-visualization-19-defining-scalar-and-vector-fields/">1 of 9 Definitions for scalar and vector fields. </a></li> <li>2 of 9 Examples of scalar and vector fields (temperature in a room vs air currents) </li> </ul> <div class="video" style="width:660;height:410;">   <div id="videoalternate166" style="width:660px;height:410px;"> <a rel="nofollow" target="_blank" href="http://www.adobe.com/go/getflashplayer"> <img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player"/> </a> </div> </div>
<img src="http://feeds.feedburner.com/~r/DougsMatlabVideoTutorials/~4/3cfrO9Tda2U" height="1" width="1"/>]]></content:encoded>
      </item>
      <item>
         <title>allstats</title>
         <link>http://feedproxy.google.com/~r/mathworks/pick/~3/WmClTTCb7mc/</link>
         <description>Bob's pick this week is Allstats by Francisco de Castro. The file is simple enough. Given a data set,x = randn(1000,1);
hist(x,100) allstats returns a list of statistical values. myStats = allstats(x)myStats = [...]</description>
         <guid isPermaLink="false">http://blogs.mathworks.com/pick/2009/10/30/allstats/</guid>
         <pubDate>Fri, 30 Oct 2009 07:42:51 -0700</pubDate>
         <content:encoded><![CDATA[<div class="content"><p><a rel="nofollow" target="_blank" href="http://www.mathworks.com/matlabcentral/fileexchange/authors/5021">Bob</a>'s pick this week is <a rel="nofollow" target="_blank" href="http://www.mathworks.com/matlabcentral/fileexchange/25572-allstats">Allstats</a> by Francisco de Castro. </p>  <p>The file is simple enough. Given a data set,</p><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);">x = randn(1000,1);
hist(x,100)</pre><img vspace="5" hspace="5" src="http://blogs.mathworks.com/images/pick/pickallstats_01.png"> <p><tt>allstats</tt> returns a list of statistical values. </p><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);">myStats = allstats(x)</pre><pre style="font-style:oblique;">myStats = min: -3.1289 max: 2.9371 mean: -0.06815 std: 1.0019 mode: -3.1289 q2p5: -1.9519 q5: -1.7128 q25: -0.73464 q50: -0.072006 q75: 0.55077 q95: 1.6351 q97p5: 1.8844
</pre><p>The mean should be close to zero,</p><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);">myStats.mean</pre><pre style="font-style:oblique;">ans = -0.06815
</pre><p>and the standard deviation should be close to one.</p><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);">myStats.std</pre><pre style="font-style:oblique;">ans = 1.0019
</pre><p>How convenient.</p> <p>As it turns out, this month the File Exchange recently celebrated a major milestone. <a rel="nofollow" target="_blank" href="http://www.mathworks.com/matlabcentral/fileexchange/25572-allstats">Allstats</a> has the honor of being the official 10,000-th submission. Congratulations to Francisco and every contributor who made this possible! Growth of the File Exchange has been absolutely amazing. </p> <p><img vspace="5" hspace="5" src="http://blogs.mathworks.com/images/pick/fxgrowth.png"> </p> <p>If only my retirement account was that impressive! (sigh)</p> <p><a rel="nofollow" target="_blank" href="http://blogs.mathworks.com/pick/?p=2486#respond">Comments?</a></p><p style="text-align:right;font-size:xx-small;font-weight:lighter;font-style:italic;color:gray;"><br /><a rel="nofollow"><span style="font-size:x-small;font-style:italic;">Get the MATLAB code <noscript>(requires JavaScript)</noscript></span></a><br /><br /> Published with MATLAB&reg; 7.9<br /></p>
</div>
<img src="http://feeds.feedburner.com/~r/mathworks/pick/~4/WmClTTCb7mc" height="1" width="1"/>]]></content:encoded>
         <category>Picks</category>
      </item>
      <item>
         <title>STEM Educational Initiative Signing, and Robotics Competitions</title>
         <link>http://feedproxy.google.com/~r/SethOnSimulink/~3/pVbF5FxgHQ8/</link>
         <description>It is not every day that I attend a speech by political
leaders of the Commonwealth of Massachusetts. Governor Patrick speeking about the value of science
technology engineering and math (STEM) education during his visit to The
MathWorks on October 14, 2009. Photo by Jeff Newcum On October 14th, 2009 Massachusetts Governor
Deval Patrick signed an executive [...]</description>
         <guid isPermaLink="false">http://blogs.mathworks.com/seth/2009/10/28/stem-educational-initiative-signing-and-robotics-competitions/</guid>
         <pubDate>Tue, 27 Oct 2009 20:00:43 -0700</pubDate>
         <content:encoded><![CDATA[<p>It is not every day that I attend a speech by political
leaders of the Commonwealth of Massachusetts.</p> <p style="font-size:80%;"><img src="http://blogs.mathworks.com/images/seth/2009Q4/stem_GovPatrickSpeech.jpg"
 alt="Governor Deval Patrick speeking about the STEM Advisory Council at the MathWorks"><br /> Governor Patrick speeking about the value of science
technology engineering and math (STEM) education during his visit to The
MathWorks on October 14, 2009. Photo by Jeff Newcum</p> <p>On October 14<sup>th</sup>, 2009 Massachusetts Governor
Deval Patrick signed an executive order to establish the Science Technology
Engineering and Math (STEM) Advisory Council. The MathWorks hosted the
gathering of local political leaders. MathWorks CEO Jack Little introduced the
Lieutenant Governor Timothy Murray and the Governor Deval Patrick to a room
filled with MathWorkers. I could describe all the formalities and go into what
this means for STEM education in Massachusetts, but other media sources covered
those topics (like <a rel="nofollow" target="_blank" href="http://www.edn.com/article/CA6701958.html?nid=2551">EDN</a>,
<a rel="nofollow"
 target="_blank" href="http://www.masshightech.com/stories/2009/10/12/daily31-Governor-Patrick-creates-Mass-STEM-council.html">Mass
High Tech</a> and <a rel="nofollow"
 target="_blank" href="http://www.mass.gov/?pageID=gov3pressrelease&amp;L=1&amp;L0=Home&amp;sid=Agov3&amp;b=pressrelease&amp;f=101409_STEM_advisory_council&amp;csid=Agov3">the
Governors official website</a>). Instead I would like to focus on some of the
tangents to the main event.</p> <p style="font-size:80%;"><img src="http://blogs.mathworks.com/images/seth/2009Q4/stem_GovPatrickSigning.jpg"
 alt="Governor Patrick signing the executive order to establish the STEM Advisory Council"><br />
Governor Patrick signing the executive order to establish the
STEM Advisory Council. Photo by Jeff Newcum</p> <p><strong>Talking to the Governor</strong></p> <p>My fellow blogger, <a rel="nofollow" target="_blank" href="http://blogs.mathworks.com/loren">Loren
Shure</a>, asked Governor Patrick what he thinks good corporate citizens can do
to support STEM education.</p> <p style="font-size:80%;"><img src="http://blogs.mathworks.com/images/seth/2009Q4/stem_DevalAndLoren.jpg"
 alt="Loren Sure expressing her interests in STEM education to Governor Patrick"><br />
Loren Shure expressing her interests in STEM Education to
the Governor. Photo by Jeff Newcum</p> <p>The Governor gave a couple examples of how companies can get
involved such as mentoring area students and engaging in student competitions. There already exist many opportunities to do this… </p> <p><strong>Mentoring</strong></p> <p>I have known many MathWorkers who volunteer at a <a rel="nofollow"
 target="_blank" href="http://www.framingham.k12.ma.us/potter.cfm">local elementary school</a> as
math tutors in preparation for standardized tests. The same school has a Lego®
Club where some of my colleagues mentor students on building robot using Lego®
Mindstorms.</p> <p><strong>Competitions</strong></p> <p>In Governor Patrick’s response to Loren, he gave a specific example
of a robotics competition, FIRST.</p> <p>Most people have heard of <a rel="nofollow" target="_blank" href="http://www.usfirst.org/">FIRST</a>
(For Inspiration and Recognition of Science and Technology). If you haven’t,
browse around the <a rel="nofollow" target="_blank" href="http://www.usfirst.org/">FIRST website</a> for a few
minutes and <em>get inspired</em> about the great things available to the next
generation of engineers and scientists. They have programs targeted at many
different age groups, from the <a rel="nofollow"
 target="_blank" href="http://www.usfirst.org/roboticsprograms/jfll/default.aspx?id=818">Junior FIRST
Lego League</a> for ages 6-9 years all the way up to “the varsity sport for the
mind” <a rel="nofollow" target="_blank" href="http://www.usfirst.org/roboticsprograms/frc/default.aspx?id=966">FIRST
Robotics Competition</a> for ages 14 to 18 years.</p> <p>Targeted toward college students is the <a rel="nofollow"
 target="_blank" href="http://www.ecocarchallenge.org/">EcoCAR Challenge</a> (which I wrote
about in a <a rel="nofollow"
 target="_blank" href="http://blogs.mathworks.com/seth/2009/10/06/mathworks-hosts-eco-car/">recent
post</a>). MathWorks is a sponsor of the competition, and some of my colleagues
act at mentors to teams. The goal is to modify GM donate vehicles in an attempt
to reduce emissions, minimize fuel consumption AND maintain consumer appeal. Those
college students involved are already on their way to careers in engineering.</p> <p>Another competition I am very excited about is <a rel="nofollow"
 target="_blank" href="http://www.etrobo.jp/ETROBO2009/">ET Robocon</a>, which MathWorks also
sponsors. The site is in Japanese, but you can see <a rel="nofollow"
 target="_blank" href="http://www.youtube.com/watch?v=w8wp29ay-x8">videos like this one</a> on
YouTube (<a rel="nofollow"
 target="_blank" href="http://www.youtube.com/results?search_query=ET+Robocon&amp;search_type=&amp;aq=f">search
for ET Robocon</a>). I see ET Robocon as an embedded software design
competition. Teams all start with a standard LEGO® NXTway robot (a two-wheel
balancing robot built from LEGOs). They have to develop an autonomous control
strategy and implement it to race robot around a pre-set track as fast as
possible. Some of my colleagues from Japan developed the balancing algorithm using
Simulink and Real-Time Workshop Embedded Coder (available on the <a rel="nofollow"
 target="_blank" href="http://www.mathworks.com/matlabcentral/fileexchange/19147-nxtway-gs-self-balancing-two-wheeled-robot-controller-design">File
Exchange here</a>). All the teams have to incorporate that balancing software
into their larger design. I learned that there are many university teams as
well as professional engineers from major companies involved in the
competition.</p> <p><strong>Now It’s Your Turn</strong></p> <p>Are you a mentor? Are you involved in any of these or other
competitions that encourage students to explore STEM fields? Leave a <a rel="nofollow"
 target="_blank" href="http://blogs.mathworks.com/seth/?p=70&amp;#comment">comment here</a> and
share your experience.</p><img src="http://feeds.feedburner.com/~r/SethOnSimulink/~4/pVbF5FxgHQ8" height="1" width="1"/>]]></content:encoded>
      </item>
      <item>
         <title>Puzzler: Ultimate Frisbee- call it!</title>
         <link>http://feedproxy.google.com/~r/DougsMatlabVideoTutorials/~3/byMfaBGqtvY/</link>
         <description>I play a fair amount of Ultimate Frisbee® between lunch across the street at Cognex and playing with Boston Ultimate Disk Alliance. Games of Ultimate start with the two teams flipping two Frisbees in the air and calling &amp;#8220;Same or different&amp;#8221; My team was trying to figure out which is the most likely [...]</description>
         <guid isPermaLink="false">http://blogs.mathworks.com/videos/2009/10/27/puzzler-ultimate-frisbee-call-it/</guid>
         <pubDate>Tue, 27 Oct 2009 12:31:07 -0700</pubDate>
         <content:encoded><![CDATA[I play a fair amount of <a rel="nofollow" target="_blank" href="http://maps.google.com/maps?f=q&#038;hl=en&#038;geocode=&#038;time=&#038;date=&#038;ttype=&#038;q=Cognex+Headquarters+1+Vision+Dr.+Natick+MA&#038;sll=45.305803,14.589844&#038;sspn=20.857325,32.695313&#038;om=1&#038;ie=UTF8&#038;hq=Cognex+Headquarters&#038;hnear=1+Vision+Dr,+Natick,+MA+01760&#038;ll=42.301071,-71.349925&#038;spn=0.007118,0.015621&#038;t=h&#038;z=17">Ultimate Frisbee® between lunch across the street at Cognex</a> and playing with <a rel="nofollow" target="_blank" href="http://www.buda.org/j2/">Boston Ultimate Disk Alliance</a>. Games of Ultimate start with the two teams flipping two Frisbees in the air and calling &#8220;Same or different&#8221; My team was trying to figure out which is the most likely outcome. <p> I made a convincing argument, but I am curious what kind of persuasive MATLAB-based &#8216;proofs&#8217; can be made. I am offering a MATLAB t-shirt to the most persuasive entry. Use <a rel="nofollow" target="_blank" href="http://www.mathworks.in/demos/matlab/publishing-from-the-editor-matlab-video-tutorial.html">published MATLAB files</a>, GUI&#8217;s, MATLAB script or function, whatever you think will be most convincing. Contest ends this time next week. <p>
<img src='http://blogs.mathworks.com/videos/../images/videos/2009/10/frisbeeflip.jpg' alt='frisbeeflip.jpg'/>
<p> Assumptions: The Frisbees (or coins) are either &#8216;heads&#8217; or &#8216;tails&#8217;. The coins may or may not be &#8216;fair&#8217; (i.e. they might be heads 80% of the time!), however the odds of heads versus tails for the two coins is the same for both coins. Send entries to hull@MathWorks.com (no .rar files please!) <a rel="nofollow" target="_blank" href="http://blogs.mathworks.com/videos/2009/11/03/puzzler-ultimate-frisbee-call-it-wrap-up/">(Here is the result of this now closed contest)</a> <p>
Frisbee® is a Registered Trademark of © 2004 Wham-o Inc. All Rights Reserved.<img src="http://feeds.feedburner.com/~r/DougsMatlabVideoTutorials/~4/byMfaBGqtvY" height="1" width="1"/>]]></content:encoded>
      </item>
      <item>
         <title>The MATLAB Editor at your fingertips</title>
         <link>http://feedproxy.google.com/~r/mathworks/desktop/~3/W_S6hXl6RiM/</link>
         <description>Our friend Yair recently described on his blog how to use the various functionalities of the Editor by accessing its Java components. I imagine for many MATLAB users, especially those not familiar with Java, this is wading into unfamiliar territory. We don&amp;#8217;t write very many APIs in Java intended for our users to access, and [...]</description>
         <guid isPermaLink="false">http://blogs.mathworks.com/desktop/2009/10/26/the-matlab-editor-at-your-fingertips/</guid>
         <pubDate>Mon, 26 Oct 2009 06:04:55 -0700</pubDate>
         <content:encoded><![CDATA[<p>Our friend Yair recently described on his blog how to use the various functionalities of the Editor by accessing its Java components. I imagine for many MATLAB users, especially those not familiar with Java, this is wading into unfamiliar territory. We don&#8217;t write very many APIs in Java intended for our users to access, and we like to abstract away the implementation components so we can be free to refactor behind the scenes. We&#8217;ve been spending time on refactoring projects, and so the Java APIs have been changing quite rapidly.</p>
<p>Over the years we&#8217;ve had a lot of requests for programmatic access to various desktop components, and we&#8217;re working on a MATLAB API for the Editor. In R2009b, this API is hidden in the product (aka undocumented), but we&#8217;re planning on bringing it out in a future release fully supported and documented. The api provides methods to manipulate the text, get information about the buffer, as well as close, save, and open editors. With the object provided users can manage the editor state, write scripts that call their favorite diff tool, open files in other programs, open the folder in the OS, etc.</p>
<p>The 9b version isn&#8217;t fully vetted or functional; it&#8217;s there to satisfy some back-end requirements. This means I&#8217;m officially saying not to use it and don&#8217;t complain when things don&#8217;t work, but&#8230; if you&#8217;d like to preview it, give it a go. All of the functionality is part of the <tt>editorservices</tt> package. A single buffer/file in the Editor is represented by the <tt>editorservices.EditorDocument</tt> class. These objects are constructed by calling the package functions such as <tt>editorservices.new()</tt>, <tt>editorservices.open()</tt>, and <tt>editorservices.getActive()</tt>.</p>
<p>Here is a full list of the package function in MATLAB R2009b. </p>
<div class="content">
<pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);">help <span style="color:#A020F0;">editorservices</span></pre>
<pre style="font-style:oblique;">Contents of editorservices: EditorDocument - Encapsulates all user accessible behavior of the MATLAB Editor
EditorUtils - Static utility methods for editorservices functions
closeGroup - Closes the MATLAB Editor and all open documents.
find - returns an already open EditorDocument for a given file name
getActive - finds the active (topmost) open buffer in the Editor
getAll - Gets all the Editors that are currently open
isOpen - true if the specified file is open in the editor
new - Creates a new buffer, with optional text
open - Opens the MATLAB Editor with the given filename
openAndGoToFunction - open a file in the editor and highlight the indicated function
openAndGoToLine - open a file in the editor and highlight the indicated line
</pre>
<p> <div style="border:1px solid;background:#CCC;padding:6px;width:95%;">You can try it out now, but keep in mind we&#8217;ve already already changed the API, fixed some of the bugs, and enhanced its functionality for its prime-time release, and so any code written with it will likely have to change when we release the documented API.</div>

<p></p>
<p>Please let us know how this new api fits (or doesn&#8217;t fit) into your workflows, and what future enhancements you&#8217;d like to see and what other Desktop components you&#8217;d like to work with programmatically.</p>
<img src="http://feeds.feedburner.com/~r/mathworks/desktop/~4/W_S6hXl6RiM" height="1" width="1"/></div>]]></content:encoded>
         <category>Editor</category>
      </item>
      <item>
         <title>Basics: Volume visualization: 1/9 Defining scalar and vector fields</title>
         <link>http://feedproxy.google.com/~r/DougsMatlabVideoTutorials/~3/rzgYQc7D9oE/</link>
         <description>This short video is the first of a series of nine that talks about volume visualization. Patrick gave this talk internally to help technical support engineers understand capabilities of MATLAB for volume visualization. I like his slow, clear, methodical presentation with great visualizations. It is the first time I have deeply understood [...]</description>
         <guid isPermaLink="false">http://blogs.mathworks.com/videos/2009/10/23/basics-volume-visualization-19-defining-scalar-and-vector-fields/</guid>
         <pubDate>Fri, 23 Oct 2009 08:26:31 -0700</pubDate>
         <content:encoded><![CDATA[This short video is the first of a series of nine that talks about volume visualization. Patrick gave this talk internally to help technical support engineers understand capabilities of MATLAB for volume visualization. <p><p> I like his slow, clear, methodical presentation with great visualizations. It is the first time I have deeply understood some of the volume visualization techniques we have. Sorry, Dr. H, but I really did not understand <a rel="nofollow" target="_blank" href="http://www.amazon.com/Div-Grad-Curl-All-That/dp/0393969975">Div, Grad, Curl and all of that</a> until Patrick explained it later in this series! <p><p> 1 of 9 Definitions for scalar and vector fields. <div class="video" style="width:660;height:410;">   <div id="videoalternate165" style="width:660px;height:410px;"> <a rel="nofollow" target="_blank" href="http://www.adobe.com/go/getflashplayer"> <img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player"/> </a> </div> </div>
<img src="http://feeds.feedburner.com/~r/DougsMatlabVideoTutorials/~4/rzgYQc7D9oE" height="1" width="1"/>]]></content:encoded>
         <category>Level: Basic</category>
      </item>
      <item>
         <title>Object Oriented Programming (MATLAB vs others)</title>
         <link>http://feedproxy.google.com/~r/mathworks/pick/~3/cGZWrKXMbSY/</link>
         <description>Jiro's pick this week is &quot;Comparison of object oriented code&quot; by our very own Stuart McGarrity. To some of you, this may be old news, but I know that not everyone is up to date on newer features. The new Object Oriented [...]</description>
         <guid isPermaLink="false">http://blogs.mathworks.com/pick/2009/10/23/object-oriented-programming-matlab-vs-others/</guid>
         <pubDate>Fri, 23 Oct 2009 04:01:49 -0700</pubDate>
         <content:encoded><![CDATA[<div class="content"><p><a rel="nofollow" target="_blank" href="http://www.mathworks.com/matlabcentral/fileexchange/authors/15007">Jiro</a>'s pick this week is <a rel="nofollow" target="_blank" href="http://www.mathworks.com/matlabcentral/fileexchange/18972-comparison-of-c-java-python-ruby-and-matlab-using-object-oriented-example">"Comparison of object oriented code"</a> by our very own <a rel="nofollow" target="_blank" href="http://www.mathworks.com/matlabcentral/fileexchange/authors/2962">Stuart McGarrity</a>. </p> <p>To some of you, this may be old news, but I know that not everyone is up to date on newer features. The new Object Oriented Programming capability that was introduced in R2008a has been highlighted several times by <a rel="nofollow" target="_blank" href="http://blogs.mathworks.com/loren/2008/08/18/when-to-create-classes-in-matlab/">Loren</a>, <a rel="nofollow" target="_blank" href="http://blogs.mathworks.com/videos/2008/07/07/advanced-matlab-class-system-for-oop-in-matlab-introduction/">Doug</a>, and <a rel="nofollow" target="_blank" href="http://blogs.mathworks.com/steve/2008/03/21/matlab-76-r2008a/">Steve</a>. </p> <p>This entry by Stuart provides a nice syntax comparisons between MATLAB and a few of the common object oriented languages (C++, Java, Python, Ruby). Take a look at the <a rel="nofollow" target="_blank" href="http://www.mathworks.com/matlabcentral/fx_files/18972/12/content/Description.html">published HTML</a> to read about it and get a quick side-by-side comparison of these languages. </p> <p><img vspace="5" hspace="5" src="http://blogs.mathworks.com/images/pick/codecompare.png"> </p> <p><i>Note: as Stuart mentions in the comments, this is a syntax comparison, and it is not meant for showcasing best practices. The <a rel="nofollow" target="_blank" href="http://www.mathworks.com/access/helpdesk/help/techdoc/matlab_oop/ug_intropage.html">documentation</a> is a good place to get such info.</i></p> <p><a rel="nofollow" target="_blank" href="http://blogs.mathworks.com/pick/?p=2485#respond">Comments</a>? </p><p style="text-align:right;font-size:xx-small;font-weight:lighter;font-style:italic;color:gray;"><br /><a rel="nofollow"><span style="font-size:x-small;font-style:italic;">Get the MATLAB code <noscript>(requires JavaScript)</noscript></span></a><br /><br /> Published with MATLAB&reg; 7.9<br /></p>
</div>
<img src="http://feeds.feedburner.com/~r/mathworks/pick/~4/cGZWrKXMbSY" height="1" width="1"/>]]></content:encoded>
         <category>Picks</category>
      </item>
      <item>
         <title>Dealing with Cells</title>
         <link>http://feedproxy.google.com/~r/mathworks/loren/~3/QrCrw0BpPHk/</link>
         <description>A customer recently asked me this question at the MATLAB Virtual Conference. Contents Question about Summing Cell Rows [...]</description>
         <guid isPermaLink="false">http://blogs.mathworks.com/loren/2009/10/21/dealing-with-cells/</guid>
         <pubDate>Wed, 21 Oct 2009 10:53:32 -0700</pubDate>
         <content:encoded><![CDATA[<div class="content"><p>A customer recently asked me this question at the <a rel="nofollow" target="_blank" href="http://events.unisfair.com/rt/matlab~virtualconf?code=hp-listing">MATLAB Virtual Conference</a>. </p>  <h3>Contents</h3> <div> <ul> <li><a rel="nofollow" href="#1">Question about Summing Cell Rows</a></li> <li><a rel="nofollow" href="#2">Example</a></li> <li><a rel="nofollow" href="#3">Answer</a></li> <li><a rel="nofollow" href="#8">Cell Array Questions</a></li> </ul> </div> <h3>Question about Summing Cell Rows<a rel="nofollow" name="1"></a></h3><pre> I was hoping you would cover cells some day. Here is a particular problem I was hoping to have a more elegant solutions for.</pre><pre> A is a cell that has String (say names) in the first column, Numbers (say scores in tests 1 and 2) in the next two columns. Assume that each cell has only one value. Is there an easier way to calculate, say the sum of the two test scores than a for loop?</pre><h3>Example<a rel="nofollow" name="2"></a></h3> <p>Let's make some sample data.</p><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);">c(1:4,1) = {<span style="color:#A020F0;">'Fred'</span> <span style="color:#A020F0;">'Alice'</span> <span style="color:#A020F0;">'Lucy'</span> <span style="color:#A020F0;">'Tom'</span>};
c(1:4,2) = { 90 80 55 102 };
c(1:4,3) = { 43 91 80 44 }</pre><pre style="font-style:oblique;">c = 'Fred' [ 90] [43] 'Alice' [ 80] [91] 'Lucy' [ 55] [80] 'Tom' [102] [44]
</pre><h3>Answer<a rel="nofollow" name="3"></a></h3> <p>To sum the entries in a row for this <a rel="nofollow" target="_blank" href="http://www.mathworks.com/access/helpdesk/help/techdoc/matlab_prog/br04bw6-98.html"><tt>cell array</tt></a>, I can simply turn the numeric values into a numeric array via comma-separated list notation, and then sum the rows. Let's see the pieces for clarity. Here's the comma-separated list. </p><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);">c{:,2:3}</pre><pre style="font-style:oblique;">ans = 90
ans = 80
ans = 55
ans = 102
ans = 43
ans = 91
ans = 80
ans = 44
</pre><p>Now place the results into a vector.</p><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);">vec = [c{:,2:3}]</pre><pre style="font-style:oblique;">vec = 90 80 55 102 43 91 80 44
</pre><p>Reshape the vector appropriately into a matrix.</p><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);">array = reshape(vec,[],2)</pre><pre style="font-style:oblique;">array = 90 43 80 91 55 80 102 44
</pre><p>Now sum the results along the rows.</p><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);">tot = sum(array,2)</pre><pre style="font-style:oblique;">tot = 133 171 135 146
</pre><p>Or, in one bigger statement, try this.</p><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);">tot = sum(reshape([c{:,2:3}],[],2),2)</pre><pre style="font-style:oblique;">tot = 133 171 135 146
</pre><h3>Cell Array Questions<a rel="nofollow" name="8"></a></h3> <p>Do you use cell arrays? Can you do what you want without undo contortions? Let me know <a rel="nofollow" target="_blank" href="http://blogs.mathworks.com/loren/?p=203#respond">here</a>. </p><p style="text-align:right;font-size:xx-small;font-weight:lighter;font-style:italic;color:gray;"><br /><a rel="nofollow"><span style="font-size:x-small;font-style:italic;">Get the MATLAB code <noscript>(requires JavaScript)</noscript></span></a><br /><br /> Published with MATLAB&reg; 7.9<br /></p>
</div>
<img src="http://feeds.feedburner.com/~r/mathworks/loren/~4/QrCrw0BpPHk" height="1" width="1"/>]]></content:encoded>
         <category>Cell Arrays</category>
      </item>
      <item>
         <title>Embedding an ICC profile into a TIFF file</title>
         <link>http://feedproxy.google.com/~r/SteveOnImageProcessing/~3/ixEWbRIZWUE/</link>
         <description>The R2009b release of MATLAB contains a new Tiff class. The primary purpose of this class is to provide lower-level access to creating and modifying image data and metadata in an existing TIFF file. Several customers have asked for the ability [...]</description>
         <guid isPermaLink="false">http://blogs.mathworks.com/steve/2009/10/20/embedding-an-icc-profile-into-a-tiff-file/</guid>
         <pubDate>Tue, 20 Oct 2009 06:15:38 -0700</pubDate>
         <content:encoded><![CDATA[<div class="content"><p>The R2009b release of MATLAB contains a new <a rel="nofollow" target="_blank" href="http://www.mathworks.com/access/helpdesk/help/techdoc/import_export/f5-123068.html#br_c_iz-1">Tiff class</a>. The primary purpose of this class is to provide lower-level access to creating and modifying image data and metadata in an existing TIFF file. </p> <p>Several customers have asked for the ability to embed an ICC profile into a TIFF file. The Image Processing Toolbox function <a rel="nofollow" target="_blank" href="http://www.mathworks.com/access/helpdesk/help/toolbox/images/index.html?/access/helpdesk/help/toolbox/images/iccread.html"><tt>iccread</tt></a> can read a profile embedded in a TIFF file, but <a rel="nofollow" target="_blank" href="http://www.mathworks.com/access/helpdesk/help/toolbox/images/index.html?/access/helpdesk/help/toolbox/images/iccwrite.html"><tt>iccwrite</tt></a> can only write a stand-alone profile file. </p> <p>Here is code using the new Tiff class to embed a profile in an existing TIFF file. Let's start by rewriting one of the Image Processing Toolbox sample PNG image files as a TIFF file. </p><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);">rgb = imread(<span style="color:#A020F0;">'peppers.png'</span>);
imwrite(rgb, <span style="color:#A020F0;">'peppers.tif'</span>);
s = dir(<span style="color:#A020F0;">'peppers.tif'</span>)</pre><pre style="font-style:oblique;">
s = name: 'peppers.tif' date: '20-Oct-2009 09:14:29' bytes: 593880 isdir: 0 datenum: 7.3407e+005 </pre><p>Now let's embed the sample profile sRGB.icm into the TIFF file we just made.</p> <p>Step 1. Read in the raw bytes of the profile file.</p><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);">fid = fopen(<span style="color:#A020F0;">'sRGB.icm'</span>);
raw_profile_bytes = fread(fid, Inf, <span style="color:#A020F0;">'uint8=&gt;uint8'</span>);
fclose(fid);</pre><p>Step 2. Initialize a Tiff object using 'r+' mode (read and modify).</p><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);">tif = Tiff(<span style="color:#A020F0;">'peppers.tif'</span>, <span style="color:#A020F0;">'r+'</span>)</pre><pre style="font-style:oblique;">
tif = TIFF File: 'peppers.tif' Mode: 'r+' Current Image Directory: 1 Number Of Strips: 77 SubFileType: Tiff.SubFileType.Default Photometric: Tiff.Photometric.RGB ImageLength: 384 ImageWidth: 512 RowsPerStrip: 5 BitsPerSample: 8 Compression: Tiff.Compression.PackBits SampleFormat: Tiff.SampleFormat.UInt SamplesPerPixel: 3 PlanarConfiguration: Tiff.PlanarConfiguration.Chunky Orientation: Tiff.Orientation.TopLeft </pre><p>Step 3. Embed the profile bytes as a TIFF tag.</p><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);">tif.setTag(<span style="color:#A020F0;">'ICCProfile'</span>, raw_profile_bytes);</pre><p>Step 4. Tell the Tiff object to update the image metadata in the file.</p><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);">tif.rewriteDirectory();</pre><p>Step 5. Close the Tiff object.</p><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);">tif.close();</pre><p>Now the TIFF file contains the profile. Notice the file size has changed.</p><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);">s = dir(<span style="color:#A020F0;">'peppers.tif'</span>)</pre><pre style="font-style:oblique;">
s = name: 'peppers.tif' date: '20-Oct-2009 09:14:30' bytes: 597828 isdir: 0 datenum: 7.3407e+005 </pre><p>And we can read in the profile using <tt>iccread</tt>. </p><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);">p = iccread(<span style="color:#A020F0;">'peppers.tif'</span>)</pre><pre style="font-style:oblique;">
p = Header: [1x1 struct] TagTable: {17x3 cell} Copyright: 'Copyright (c) 1999 Hewlett-Packard Company' Description: [1x1 struct] MediaWhitePoint: [0.9505 1 1.0891] MediaBlackPoint: [0 0 0] DeviceMfgDesc: [1x1 struct] DeviceModelDesc: [1x1 struct] ViewingCondDesc: [1x1 struct] ViewingConditions: [1x1 struct] Luminance: [76.0365 80 87.1246] Measurement: [1x1 struct] Technology: 'Cathode Ray Tube Display' MatTRC: [1x1 struct] PrivateTags: {} Filename: 'peppers.tif' </pre><p>It would be logical to enhance <tt>iccwrite</tt> to make this easier for you. We'll look into that, although I'm not sure when that might happen. </p><p style="text-align:right;font-size:xx-small;font-weight:lighter;font-style:italic;color:gray;"><br /><a rel="nofollow"><span style="font-size:x-small;font-style:italic;">Get the MATLAB code <noscript>(requires JavaScript)</noscript></span></a><br /><br /> Published with MATLAB&reg; 7.9<br /></p>
</div>
<img src="http://feeds.feedburner.com/~r/SteveOnImageProcessing/~4/ixEWbRIZWUE" height="1" width="1"/>]]></content:encoded>
         <category>Uncategorized</category>
      </item>
      <item>
         <title>Is 7 your lucky number?</title>
         <link>http://feedproxy.google.com/~r/mathworks/desktop/~3/_bZm1qIJXOU/</link>
         <description>I&amp;#8217;d like to welcome guest blogger Ken Atwell from the MATLAB Product Management team this week to talk about our support of Windows 7. Here at The MathWorks we&amp;#8217;ve been using and testing MATLAB against pre-releases of Windows 7 for some time now. And we know we&amp;#8217;re not the only ones, as we&amp;#8217;ve seen thousands of [...]</description>
         <guid isPermaLink="false">http://blogs.mathworks.com/desktop/2009/10/19/is-7-your-lucky-number/</guid>
         <pubDate>Mon, 19 Oct 2009 05:30:07 -0700</pubDate>
         <content:encoded><![CDATA[<p><i><br />
I&#8217;d like to welcome guest blogger Ken Atwell from the MATLAB Product Management team this week to talk about our support of Windows 7.<br />
</i></p>
<div align="center"><img border="0" src="http://blogs.mathworks.com/images/desktop//ken_atwell_windows_7/matlab_windows_7.png"></div>
<p>Here at The MathWorks we&#8217;ve been using and testing MATLAB against pre-releases of Windows 7 for some time now. And we know we&#8217;re not the only ones, as we&#8217;ve seen thousands of MATLAB activations under Windows 7, even though Windows 7 will not be formally release until the end of this week! I&#8217;m happy to report that we&#8217;ve fully tested and are now officially supporting the 32-bit and 64-bit versions of R2009a (including Student Version) and R2009b. You can see read our official statement <a rel="nofollow" target="_blank" href="http://www.mathworks.com/support/solutions/en/data/1-92CVOW">here</a>, and we&#8217;ve updated our <a rel="nofollow" target="_blank" href="http://www.mathworks.com/support/sysreq/current_release">System Requirements pages</a> in the last several days accordingly.</p>
<p>We expect a smooth MATLAB experience when using these modern releases of MATLAB on Windows 7. We expect older versions of MATLAB to work as well (see <a rel="nofollow" target="_blank" href="http://www.mathworks.com/support/solutions/en/data/1-92CVOW">our statement</a> for potential gotchas), but is not a supported configuration. If you&#8217;re using R2009a, we did find one glitch unique to Windows 7 that was fixed for R2009b: If you shell out to the console with the ! shell escape &#8220;operator&#8221; in MATLAB, Ctrl+C often will not break out of an operation should you choose to abort it. There is no work-around beyond &#8220;don&#8217;t do that&#8221;. Again, this was resolved for 9b and seems to impact Windows 7 only.</p>
<p>Here are two nice usability improvements that I thought I would share:</p>
<ol>
<li>If you mouse over the MATLAB icon in the Windows taskbar, you&#8217;ll get thumbnails of all of your MATLAB windows. This may be helpful when you need to locate an undocked Figure window of a GUI that got itself stacked under the MATLAB Desktop or another application.
<div align="center">
<a rel="nofollow" target="_blank" href="http://blogs.mathworks.com/images/desktop/ken_atwell_windows_7/windows_7_thumbs.png"><img border="0" src="http://blogs.mathworks.com/images/desktop/ken_atwell_windows_7/windows_7_thumbs_small.png"></a><br />

</div>
</li>
<li>The &#8220;Windows&#8221; key on your keyboard will pop-up the Start menu, which you can quickly filter by typing a character or two in the name of the app you wish to launch. No more hunting through the Program Files hierarchy! For me, Windows-&gt;&#8221;fi&#8221; is enough to find Firefox, Windows-&gt;&#8221;it&#8221; is enough to find iTunes, and (of course) Windows-&gt;&#8221;ma&#8221; finds MATLAB. This is great way to find and launch frequently-used applications while keeping your hands on the keyboard. (And, okay, I admit this feature was introduced in Windows Vista, but it is just too good not to share!)</li>
</ol>
<p>What are your plans for migrating to Windows 7 (or are you already there)? Any productivity tips for fellow MATLAB users?</p>
<p><i>-by Ken Atwell, The MathWorks</i></p>
<img src="http://feeds.feedburner.com/~r/mathworks/desktop/~4/_bZm1qIJXOU" height="1" width="1"/>]]></content:encoded>
         <category>Windows</category>
      </item>
      <item>
         <title>Faster morphological reconstruction in R2009b</title>
         <link>http://feedproxy.google.com/~r/SteveOnImageProcessing/~3/goLR2XpBknQ/</link>
         <description>We've been working for a while now to make Image Processing Toolbox functions run faster. The R2009b release notes mention several performance improvements. We've gotten some feedback, though, that our release notes are pretty vague about the improvements. I can't argue with that impression. [...]</description>
         <guid isPermaLink="false">http://blogs.mathworks.com/steve/2009/10/19/faster-imreconstruct-in-r2009b/</guid>
         <pubDate>Mon, 19 Oct 2009 00:00:36 -0700</pubDate>
         <content:encoded><![CDATA[<div class="content"><p>We've been working for a while now to make Image Processing Toolbox functions run faster. The <a rel="nofollow" target="_blank" href="http://www.mathworks.com/access/helpdesk/help/toolbox/images/rn/rn_intro.html">R2009b release notes</a> mention several performance improvements. We've gotten some feedback, though, that our release notes are pretty vague about the improvements. I can't argue with that impression. We tend to be vague because performance optimization is a very complex topic, and it can be quite difficult to characterize performance changes in a way that is brief, understandable, and accurate for every user's own hardware and data. </p> <p>But I've decided to start posting more detailed information here about the performance improvements. I have more flexibility (and room!) here than we have with the release notes. </p> <p>Today I'll tackle <a rel="nofollow" target="_blank" href="http://www.mathworks.com/access/helpdesk/help/toolbox/images/index.html?/access/helpdesk/help/toolbox/images/imreconstruct.html"><tt>imreconstruct</tt></a>, which performs morphological reconstruction. Reconstruction is a very useful operation that I've written about here before. For example, see my <a rel="nofollow" target="_blank" href="http://blogs.mathworks.com/steve/2008/07/14/opening-by-reconstruction/">post from last year on opening by reconstruction</a>. Several other Image Processing Toolbox functions call <tt>imreconstruct</tt>, including <tt>imclearborder</tt>, <tt>imfill</tt>, <tt>imhmax</tt>, <tt>imhmin</tt>, <tt>imextendedmax</tt>, <tt>imextendedmin</tt>, and <tt>imimposemin</tt>. </p> <p>Let me use the <a rel="nofollow" target="_blank" href="http://blogs.mathworks.com/steve/2008/07/14/opening-by-reconstruction/">opening by reconstruction example</a> as a benchmark case. </p><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);">url = <span style="color:#A020F0;">'http://blogs.mathworks.com/images/steve/2008/book_text.png'</span>;
text = imread(url);
imshow(text, <span style="color:#A020F0;">'InitialMagnification'</span>, 25)
title(<span style="color:#A020F0;">'918-by-2018 image displayed at 25% magnification'</span>)</pre><img vspace="5" hspace="5" src="http://blogs.mathworks.com/images/steve/2009/imreconstruct_performance_01.png"> <p>The example task was to find letters containing vertical strokes by eroding with a vertical structuring element and then performing reconstruction. </p><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);">se = strel(ones(51, 1));
marker = imerode(text, se);
text2 = imreconstruct(marker, text);
imshow(text2, <span style="color:#A020F0;">'InitialMagnification'</span>, 25)
title(<span style="color:#A020F0;">'Output image displayed at 25% magnification'</span>)</pre><img vspace="5" hspace="5" src="http://blogs.mathworks.com/images/steve/2009/imreconstruct_performance_02.png"> <p>So how long does that call to <tt>imreconstruct</tt> take in R2009b? I'll use my function <a rel="nofollow" target="_blank" href="http://www.mathworks.com/matlabcentral/fileexchange/18798-timeit-benchmarking-function"><tt>timeit</tt></a>, which you can download from the MATLAB Central File Exchange. </p><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);">timeit(@() imreconstruct(marker, text))</pre><pre style="font-style:oblique;">
ans = 0.0241 </pre><p>That time is about 45 times faster than the same operation performed in R2009a. Note that I'm running on two-core computer; the improved <tt>imreconstruct</tt> is multithreaded, so the performance improvement would be greater on a four-core computer, for example. </p> <p>Now let's time gray-scale reconstruction. I'll make a 1024-by-1024 test image and compute a marker image by subtraction. This kind of operation is often used to suppress small peaks in an image. </p><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);">I = repmat(imread(<span style="color:#A020F0;">'rice.png'</span>), 4, 4);
marker = I - 20;
timeit(@() imreconstruct(marker, I))</pre><pre style="font-style:oblique;">
ans = 0.0201 </pre><p>This time is about 30 times faster than R2009a, again running on my two-core laptop.</p> <p>Now for some key caveats you should know. For now, the performance improvements described here only work for 2-D inputs that are uint8, uint16, or single, and only when the specified connectivity is 4 or 8. We'll be working in the future to extend the speed improvements to other inputs. </p><p style="text-align:right;font-size:xx-small;font-weight:lighter;font-style:italic;color:gray;"><br /><a rel="nofollow"><span style="font-size:x-small;font-style:italic;">Get the MATLAB code <noscript>(requires JavaScript)</noscript></span></a><br /><br /> Published with MATLAB&reg; 7.9<br /></p>
</div>
<img src="http://feeds.feedburner.com/~r/SteveOnImageProcessing/~4/goLR2XpBknQ" height="1" width="1"/>]]></content:encoded>
         <category>Uncategorized</category>
      </item>
      <item>
         <title>Radar Tracking in Simulink: Variable Size Signals</title>
         <link>http://feedproxy.google.com/~r/SethOnSimulink/~3/UNJBUdJ72hE/</link>
         <description>This week I welcome guest blogger Aarti Ramani to talk about a long requested feature, variable size signals in Simulink. Depending on target ranges, radar systems operate in
different modes (different lengths of data etc). Let’s assume we have two
planes at two different altitudes. Now, what happens if there is a new plane in
sight? Since the number [...]</description>
         <guid isPermaLink="false">http://blogs.mathworks.com/seth/2009/10/16/radar-tracking-in-simulink-variable-size-signals/</guid>
         <pubDate>Fri, 16 Oct 2009 12:00:42 -0700</pubDate>
         <content:encoded><![CDATA[This week I welcome guest blogger Aarti Ramani to talk about a long requested feature, variable size signals in Simulink. <img src="http://blogs.mathworks.com/images/seth/2009Q4/Aarti_Ramani.jpg" alt="Aarti Ramani"/> <p>Depending on target ranges, radar systems operate in
different modes (different lengths of data etc). Let’s assume we have two
planes at two different altitudes. Now, what happens if there is a new plane in
sight? Since the number of targets being detected by the radar is now changing,
how would you use Simulink to add this plane to its tracking list? </p> <p><img src="http://blogs.mathworks.com/images/seth/2009Q4/radar_length_mode.png" alt="Radar mode and length"></p> <p>A short and simple answer to this question is: <a rel="nofollow"
 target="_blank" href="http://www.mathworks.com/access/helpdesk/help/toolbox/simulink/ug/br4lzsy.html">Variable
Size Signals</a>. </p> <p>I’ve read many customer requests wanting to be able to
change the dimensions of their Simulink variables while the simulation runs. Be
it a radar system which needs to operate in different modes based on its target
range to a simple combustion engine that needs to change its frame size based
on the number of samples per cycle, each of these system dynamics work with
signals whose sizes change during model execution.</p> <p>Although, earlier I had to tell our customers that Simulink
did not have this capacity and you could not change a model’s signals
dimensions during execution; with R2009b, Simulink now supports variable-size
inputs and outputs in over 40 Simulink blocks.</p> <p><strong>How does one create a variable size signal? </strong></p> <p>There are several methods of creating a variable size
signal: Switch blocks; Multi-Switch blocks with different input sizes; a Selector
block indexing options or custom code blocks (S-functions and Embedded MATLAB
blocks). </p> <p>A common way of generating variable-size signals is to use a
Switch block for which each of the input signals differ in size. The Switch
Block now allows variable size signals to be passed in as inputs: </p> <p><img src="http://blogs.mathworks.com/images/seth/2009Q4/switchBlockParams.png" alt="Block parameters for the Switch Block"></p> <p>By simply selecting the option “Allow different data input
sizes”, you can obtain a variable size output signal whose dimensions change
with time.</p> <p>As an
experiment, let us look at a simple demo model “sldemo_varsize_basic.mdl”. This demonstration
contains examples of how to use variable-size signals in a Simulink model, and
to show what kind of operations you can apply to them.</p> <p><img src="http://blogs.mathworks.com/images/seth/2009Q4/varSizeBasic_diagram.png" alt="Variable size signals in a Simulink diagram."></p> <p>Look at
how the Switch block, allowing 2 inputs of different dimensions, can be used
for operations like addition, vector concatenation etc.</p> <p>You can also use the
“Selector” blocks to create a variable size signal. The Selector block generates as
output selected or reordered elements of an input vector, matrix, or
multidimensional signal. Using the “Starting and ending indices (port)”
indexing option, you can allow inputs of variable dimensions to generate
variable size signals.</p> <p><img src="http://blogs.mathworks.com/images/seth/2009Q4/selectorBlockParams.png" alt="Selector block parameters"></p> <p>You can use the Selector block to subreferece a matrix as shown below:</p> <p><img src="http://blogs.mathworks.com/images/seth/2009Q4/varSizeBasic_selector.png" alt="Variable size signals from the selector block"></p> <p><strong>How can I get the current dimensions or width of a
variable-size signal?</strong></p> <p>You can use the Probe block to output the width of a signal.
</p> <p><img src="http://blogs.mathworks.com/images/seth/2009Q4/probeBlockParams.png" alt="Probe block parameters"></p> <p>The Probe
allows you to visualize and save the signal dimensions and view the I/O and
state data for blocks selected. This could also be used in a calculation that
requires sample size information.</p> <p><strong>How can I convert a variable-size signal into a
fixed-size signal?</strong></p> <p>To convert a variable size signal into a fixed size signal,
you can use the “Assignment” block. The variable-size signal feeds into the second
input port of the Assignment block and can be used to convert the incoming
signal into a fixed size signal. </p> <p>By allowing signal sizes in Simulink models to vary during
execution, one can easily model systems with varying environments, resources,
and constraints. So, coming back to our radar system, using variable size
signals, you can now create a conceptual air traffic control (ATC) radar
simulation based on your radar range equation(s):</p> <p><img src="http://blogs.mathworks.com/images/seth/2009Q4/aero_atc.png" alt="Simulink radar model"></p> <p>For more details on how this snazzy feature works, check out
the <a rel="nofollow"
 target="_blank" href="http://www.mathworks.com/access/helpdesk/help/toolbox/simulink/ug/br4lzsy.html">Variable
Sizing documentation</a>.</p> <p><strong>Now it’s your turn</strong></p> <p>Do you plan to upgrade to R2009b and use variable size signals? Leave a <a rel="nofollow" target="_blank" href="http://blogs.mathworks.com/seth/?p=69&#comment">comment here</a> and tell me what you plan to model.</p>
<img src="http://feeds.feedburner.com/~r/SethOnSimulink/~4/UNJBUdJ72hE" height="1" width="1"/>]]></content:encoded>
      </item>
      <item>
         <title>Friday links</title>
         <link>http://feedproxy.google.com/~r/SteveOnImageProcessing/~3/By5RSleLraY/</link>
         <description>Contour tracing - tutorial and algorithms List of computer vision research groups worldwide Camera Calibration Toolbox for MATLAB Daimler Pedestrian Benchmarks - for detection and classification The Berkeley Segmentation Dataset and Benchmark</description>
         <guid isPermaLink="false">http://blogs.mathworks.com/steve/2009/10/16/friday-links-2/</guid>
         <pubDate>Fri, 16 Oct 2009 08:16:18 -0700</pubDate>
         <content:encoded><![CDATA[<ul><li><a rel="nofollow" target="_blank" href="http://www.imageprocessingplace.com/downloads_V3/root_downloads/tutorials/contour_tracing_Abeer_George_Ghuneim/index.html">Contour tracing - tutorial and algorithms</a></li> <li><a rel="nofollow" target="_blank" href="http://peipa.essex.ac.uk/info/groups.html">List of computer vision research groups worldwide</a></li> <li><a rel="nofollow" target="_blank" href="http://www.vision.caltech.edu/bouguetj/calib_doc/">Camera Calibration Toolbox for MATLAB</a></li> <li><a rel="nofollow" target="_blank" href="http://www.science.uva.nl/research/isla/downloads/pedestrians/index.html">Daimler Pedestrian Benchmarks - for detection and classification</a></li> <li><a rel="nofollow" target="_blank" href="http://www.eecs.berkeley.edu/Research/Projects/CS/vision/bsds/">The Berkeley Segmentation Dataset and Benchmark</a></li> </ul><img src="http://feeds.feedburner.com/~r/SteveOnImageProcessing/~4/By5RSleLraY" height="1" width="1"/>]]></content:encoded>
         <category>Uncategorized</category>
      </item>
      <item>
         <title>Circular Statistics Toolbox (Directional Statistics)</title>
         <link>http://feedproxy.google.com/~r/mathworks/pick/~3/zZQmyJH62s8/</link>
         <description>Bob's pick this week is Circular Statistics Toolbox (Directional Statistics) by Philipp Berens. I remember lots of A-ha moments in college when I realized the significance of yet another application for Fourier transforms. [...]</description>
         <guid isPermaLink="false">http://blogs.mathworks.com/pick/2009/10/16/circular-statistics-toolbox-directional-statistics/</guid>
         <pubDate>Fri, 16 Oct 2009 04:04:45 -0700</pubDate>
         <content:encoded><![CDATA[<div class="content"><p><a rel="nofollow" target="_blank" href="http://www.mathworks.com/matlabcentral/fileexchange/authors/5021">Bob</a>'s pick this week is <a rel="nofollow" target="_blank" href="http://www.mathworks.com/matlabcentral/fileexchange/10676-circular-statistics-toolbox-directional-statistics">Circular Statistics Toolbox (Directional Statistics)</a> by Philipp Berens. </p>  <p>I remember lots of A-ha moments in college when I realized the significance of yet another application for Fourier transforms. For example, calculation of power spectral density in signal processing. The central limit theorem was another pleasant surprise. This submission stirred those memories: not unlike bumping into an old friend you haven't seen for a long time. Now all I need is a compelling problem that requires circular or directional statistics so I can truly internalize the value of these tools for myself. </p> <p>Philipp first submitted this file in January 2007. There have been a number of review comments over the years. It is currently rated 4.4 (on the 5 point scale). </p> <p><img vspace="5" hspace="5" src="http://blogs.mathworks.com/images/pick/circstatsfeedback.png"> </p> <p>Downloads have averaged almost 9 per day over the past month as well. So others clearly appreciate it. I also appreciate that Philipp recently updated the submission in response to feedback from others. In addition, follow the Acknowledgements trail to see that <a rel="nofollow" target="_blank" href="http://www.mathworks.com/matlabcentral/fileexchange/10676-circular-statistics-toolbox-directional-statistics">Circular Statistics Toolbox (Directional Statistics)</a> was inspired by <a rel="nofollow" target="_blank" href="http://www.mathworks.com/matlabcentral/fileexchange/4810-circular-cross-correlation">Circular Cross Correlation</a> which also inspired <a rel="nofollow" target="_blank" href="http://www.mathworks.com/matlabcentral/fileexchange/24342">Fast Circular (Periodic) Cross Correlation</a>. That's social computing. Keep up the great work, everyone. </p> <p><a rel="nofollow" target="_blank" href="http://blogs.mathworks.com/pick/?p=2482#respond">Comments?</a></p><p style="text-align:right;font-size:xx-small;font-weight:lighter;font-style:italic;color:gray;"><br /><a rel="nofollow"><span style="font-size:x-small;font-style:italic;">Get the MATLAB code <noscript>(requires JavaScript)</noscript></span></a><br /><br /> Published with MATLAB&reg; 7.9<br /></p>
</div>
<img src="http://feeds.feedburner.com/~r/mathworks/pick/~4/zZQmyJH62s8" height="1" width="1"/>]]></content:encoded>
         <category>Picks</category>
      </item>
      <item>
         <title>Concatenating structs</title>
         <link>http://feedproxy.google.com/~r/mathworks/loren/~3/vZ95fGBo-JQ/</link>
         <description>From time to time, I get asked or see queries about how to concatenate two struct arrays to merge the fields. There's even a section in the documentation covering this topic. I thought I'd show it here to help people out. [...]</description>
         <guid isPermaLink="false">http://blogs.mathworks.com/loren/2009/10/15/concatenating-structs/</guid>
         <pubDate>Thu, 15 Oct 2009 11:18:06 -0700</pubDate>
         <content:encoded><![CDATA[<div class="content"><p>From time to time, I get asked or see queries about how to concatenate two <a rel="nofollow" target="_blank" href="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/struct.html"><tt>struct</tt></a> arrays to merge the fields. There's even a section in the <a rel="nofollow" target="_blank" href="http://www.mathworks.com/access/helpdesk/help/techdoc/matlab_prog/br04bw6-38.html#br04bw6-78">documentation</a> covering this topic. I thought I'd show it here to help people out. </p>  <h3>Contents</h3> <div> <ul> <li><a rel="nofollow" href="#1">Example Data</a></li> <li><a rel="nofollow" href="#10">mergeStruct</a></li> <li><a rel="nofollow" href="#11">Do You Need to Merge struct data?</a></li> </ul> </div> <h3>Example Data<a rel="nofollow" name="1"></a></h3> <p>Suppose I've got some system for which I have collected information on a couple of individuals, including their names and ages. </p><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);">s1.name = <span style="color:#A020F0;">'fred'</span>;
s1.age = 42;
s1(2).name = <span style="color:#A020F0;">'alice'</span>;
s1(2).age = 29;</pre><p>Later, I go back and collect the individual's heights (in cm).</p><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);">s2.height = 170;
s2(2).height = 160;</pre><p>It would be great to merge these arrays now.</p><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);">s1
s2</pre><pre style="font-style:oblique;">s1 = 1x2 struct array with fields: name age
s2 = 1x2 struct array with fields: height
</pre><p>Let me collect the field names.</p><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);">fn1 = fieldnames(s1);
fn2 = fieldnames(s2);
fn = [fn1; fn2];</pre><p>Next, I ensure the fieldnames are unique.</p><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);">ufn = length(fn) == unique(length(fn))</pre><pre style="font-style:oblique;">ufn = 1
</pre><p>Next let me convert the data in my structs into cell arrays using <a rel="nofollow" target="_blank" href="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/struct2cell.html"><tt>struct2cell</tt></a>. </p><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);">c1 = struct2cell(s1)
c2 = struct2cell(s2)</pre><pre style="font-style:oblique;">c1(:,:,1) = 'fred' [ 42]
c1(:,:,2) = 'alice' [ 29]
c2(:,:,1) = [170]
c2(:,:,2) = [160]
</pre><p>Next I merge the data from the 2 cell arrays.</p><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);">c = [c1;c2]</pre><pre style="font-style:oblique;">c(:,:,1) = 'fred' [ 42] [ 170]
c(:,:,2) = 'alice' [ 29] [ 160]
</pre><p>And finally, I construct the new struct using <a rel="nofollow" target="_blank" href="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/cell2struct.html"><tt>cell2struct</tt></a>. </p><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);">s = cell2struct(c,fn,1)</pre><pre style="font-style:oblique;">s = 1x2 struct array with fields: name age height
</pre><p>I can check the output now.</p><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);">s(1)
s(2)</pre><pre style="font-style:oblique;">ans = name: 'fred' age: 42 height: 170
ans = name: 'alice' age: 29 height: 160
</pre><h3>mergeStruct<a rel="nofollow" name="10"></a></h3> <p>Here's the function <tt>mergeStruct</tt> that I created to encapsulate the steps in this process, including some error checks. </p><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);">dbtype <span style="color:#A020F0;">mergeStruct</span></pre><pre style="font-style:oblique;">
1 function sout = mergestruct(varargin)
2 %MERGESTRUCT Merge structures with unique fields.
3 4 % Copyright 2009 The MathWorks, Inc.
5 6 % Start with collecting fieldnames, checking implicitly 7 % that inputs are structures.
8 fn = [];
9 for k = 1:nargin
10 try
11 fn = [fn ; fieldnames(varargin{k})];
12 catch MEstruct
13 throw(MEstruct)
14 end
15 end
16 17 % Make sure the field names are unique.
18 if length(fn) ~= length(unique(fn))
19 error('mergestruct:FieldsNotUnique',...
20 'Field names must be unique');
21 end
22 23 % Now concatenate the data from each struct. Can't use 24 % structfun since input structs may not be scalar.
25 c = [];
26 for k = 1:nargin
27 try
28 c = [c ; struct2cell(varargin{k})];
29 catch MEdata
30 throw(MEdata);
31 end
32 end
33 34 % Construct the output.
35 sout = cell2struct(c, fn, 1);
</pre><h3>Do You Need to Merge struct data?<a rel="nofollow" name="11"></a></h3> <p>Do you ever need to merge data stored in structs when you gather new information? Or are your structs static in nature? If the information you collect is always the same sort of information, then you probably know the form of the structure when you start, even if all the data isn't available at first. </p> <p>There is <a rel="nofollow" target="_blank" href="http://www.mathworks.com/matlabcentral/fileexchange/7842">code</a> on the File Exchange to concatenate structures; I confess I have not tried it, but it is highly rated. Does this post or the File Exchange contribution help your work? Let me know <a rel="nofollow" target="_blank" href="http://blogs.mathworks.com/loren/?p=XXX#respond">here</a>. </p><p style="text-align:right;font-size:xx-small;font-weight:lighter;font-style:italic;color:gray;"><br /><a rel="nofollow"><span style="font-size:x-small;font-style:italic;">Get the MATLAB code <noscript>(requires JavaScript)</noscript></span></a><br /><br /> Published with MATLAB&reg; 7.9<br /></p>
</div>
<img src="http://feeds.feedburner.com/~r/mathworks/loren/~4/vZ95fGBo-JQ" height="1" width="1"/>]]></content:encoded>
         <category>Structures</category>
      </item>
      <item>
         <title>MATLAB Virtual Conference - “the high point of geekism this year”</title>
         <link>http://feedproxy.google.com/~r/SteveOnImageProcessing/~3/PR9KaIxmyIU/</link>
         <description>I spent all of yesterday interacting with visitors to the MATLAB Virtual Conference. It was great fun! A blogger wrote that it was the &quot;high point of geekism and nerdity of this year.&quot; (I think that was intended to be a compliment!) It's not too late to hear the presentations. You can still visit the conference [...]</description>
         <guid isPermaLink="false">http://blogs.mathworks.com/steve/2009/10/15/matlab-virtual-conference-the-high-point-of-geekism-this-year/</guid>
         <pubDate>Thu, 15 Oct 2009 10:02:42 -0700</pubDate>
         <content:encoded><![CDATA[<p>
I spent all of yesterday interacting with visitors to the MATLAB Virtual Conference. It was great fun! A <a rel="nofollow" target="_blank" href="http://mindsync.wordpress.com/2009/10/14/matlab-virtual-conference/">blogger</a> wrote that it was the "high point of geekism and nerdity of this year." (I think that was intended to be a compliment!)
</p> <p>
It's not too late to hear the presentations. You can still <a rel="nofollow" target="_blank" href="http://events.unisfair.com/rt/matlab~virtualconf?code=hp-listing">visit the conference link</a> and listen to the talks there, or you can download them as podcasts.
</p> <p>
I started out early in the morning in the Image and Video Processing booth, participating in the group chat there. When it got busy it was a bit challenging to follow all the conversational threads, but I think most people got their questions answered, and I came away with a lot of good product feedback.
</p> <p>
Then I went over to hear Tom Kush and Roy Lurie give their "MATLAB Universe" keynote address. If you want to hear about the world-wide impact of MATLAB and get some insight into where we think MATLAB is going, check out this talk. (I didn't get a chance to listen to the other talks yesterday, but I will later.)
</p> <p>
The experience reminded me of some of the MATLAB user conferences in the 1990s. One of the only times I've ever heard company president <a rel="nofollow" target="_blank" href="http://www.mathworks.com/company/aboutus/founders/jacklittle.html">Jack Little</a> tell a joke was during his keynote address at the 1995 user conference in Cambridge, Massachusetts. We had been working for several years on MATLAB 5, which was going to be a huge release. Conference attendees had been promised a preview. So at the opening of the conference, in an enormous ballroom, Jack fired up the development build of MATLAB 5 on the big screen and started to talk about all the exciting new features to come. He said there would be a few changes that might take some getting used to. (We developers were sitting on the back row, holding our breath.) Jack explained that we had decided to adopt RPN (<a rel="nofollow" target="_blank" href="http://en.wikipedia.org/wiki/Reverse_Polish_notation">Reverse Polish Notation</a>, popular in HP engineering calculators such as my beloved <a rel="nofollow" target="_blank" href="http://en.wikipedia.org/wiki/HP-15C">HP 15C</a>) in MATLAB. He proceeded to type something like:
</p> <pre>
&gt;&gt; 5 3 +
</pre> <p>
There was a massive collective gasp! from the audience as we about fell off our chairs in the back trying not to laugh out loud.
</p> <p>
To any reader who was there (and is still recovering), I can only say, "We're sorry!" ;-)
</p> <p>
OK, back to the present. Later in the day I gave a talk on MATLAB array indexing techniques that are useful for image processing, borrowing heavily from material I <a rel="nofollow" target="_blank" href="http://blogs.mathworks.com/steve/category/indexing/">originally posted here on the blog</a>. I was afraid the material would be too narrowly focused, but the audience stayed with me to the end and then asked a bunch of great questions about my last topic, <a rel="nofollow" target="_blank" href="http://blogs.mathworks.com/steve/2008/02/25/neighbor-indexing-2/">neighbor indexing</a>, which was pretty advanced.
</p> <p>
For the first five minutes of the talk (which I recorded a couple of weeks ago), I was in a rapidly increasing panic, because a 2-second echo was making the audio completely unintelligible! I bolted out of my office to find someone to help. Kevin calmed me down and helped me figure out that I had a second, forgotten, browser window open to the talk, and the echo was coming there. Boy did I feel silly. Thanks, Kevin!
</p> <p>
Readers, I have two questions for you. First, did you attend any of the original MATLAB user conferences in the 90s? Any favorite memories to share?
</p> <p>
Second, did you attend the virtual conference yesterday? What did you think? If we do it again, what can we do better next time?
</p> <p>
Thanks for taking the time to give us your feedback.
</p>
<img src="http://feeds.feedburner.com/~r/SteveOnImageProcessing/~4/PR9KaIxmyIU" height="1" width="1"/>]]></content:encoded>
         <category>Uncategorized</category>
      </item>
      <item>
         <title>The history of keyboard shortcuts in MATLAB</title>
         <link>http://feedproxy.google.com/~r/mathworks/desktop/~3/cGBL9jjwVeQ/</link>
         <description>I&amp;#8217;d like to welcome guest blogger Christina Roberts from the MATLAB Editor team. Christina was the lead developer on the configurable keyboard shortcuts feature. My last post gave an overview of how to use the new keyboard shortcut preference panel. This post is going to delve into the history of keyboard shortcuts in MATLAB, which will [...]</description>
         <guid isPermaLink="false">http://blogs.mathworks.com/desktop/2009/10/12/the-history-of-keyboard-shortcuts-in-matlab/</guid>
         <pubDate>Mon, 12 Oct 2009 05:17:44 -0700</pubDate>
         <content:encoded><![CDATA[<p><i><br />
I&#8217;d like to welcome guest blogger Christina Roberts from the MATLAB Editor team. Christina was the lead developer on the configurable keyboard shortcuts feature.<br />
</i></p>
<p><a rel="nofollow" target="_blank" href="http://blogs.mathworks.com/desktop/2009/09/28/configurable-keyboard-shortcuts-have-arrived/">My last post</a> gave an overview of how to use the new keyboard shortcut preference panel. This post is going to delve into the history of keyboard shortcuts in MATLAB, which will help make it clearer why we decided to change some of our default keyboard shortcut assignments.</p>
<p>The MATLAB desktop was developed over many years by a number of different developers. Although the developers attempted to follow platform standards for common actions, some MATLAB-specific actions were assigned different keyboard shortcuts in different desktop tools, depending on which developer created the tool. A good example of this, illustrated below in the legacy R2009a Windows Default Set, is the <em>Open Selection</em> action available across the desktop. In addition to the four different shortcuts that you can see below, there are a few tools with the action that have no shortcut at all. </p>
<div align="center">
<img border="0" src="http://blogs.mathworks.com/images/desktop/christina_roberts_keyboard_shortcuts_history/open_selection.png">
</div>
<p>Further complicating issues, the original keyboard shortcuts assigned to the Command Window were based on Emacs, regardless of platform. Other platform-specific shortcuts were also added to the Command Window, as long as they did not conflict with existing Emacs shortcuts; for example, Ctrl+O was added on Windows to perform <em>Open</em>, but Ctrl+A could not be assigned to the Command Window’s <em>Select All</em> action because Ctrl+A was the Emacs assignment for moving the cursor to the beginning of the line.</p>
<p>Before long, customers began asking for the ability to configure keyboard shortcuts in the Editor and Command Window, which were the primary desktop tools at the time. To help accommodate those requests, three default sets were developed for the Editor and the Command Window, and users could choose between those sets independently (with the caveat that the Macintosh set was only available on the Macintosh platform). To maintain backwards compatibility, the defaults remained as they had been, even though they were inconsistent between the Editor and the Command Window—the Command Window stayed with the Emacs-based shortcuts on all platforms, but the keyboard shortcut set selected for the Editor by default varied by platform. This was very confusing for new MATLAB users, who expected a more consistent user experience. </p>
<div align="center">
<img border="0" src="http://blogs.mathworks.com/images/desktop/christina_roberts_keyboard_shortcuts_history/mac.png">
</div>
<p>As MATLAB continued to evolve, additional tools were added to the desktop, and their keyboard shortcuts were hard-coded to the values that the individual developers felt made sense. So although users appreciated having some choice of keyboard shortcuts in the Editor and Command Window, we continued to receive many requests for customization of individual keyboard shortcuts across the whole desktop. This was particularly needed for customers using certain non-English keyboards, which simply could not trigger some of our default shortcuts.</p>
<p>Presented with the challenge of creating a new keyboard shortcut infrastructure, I had several requirements. I wanted to provide a way to unify keyboard shortcuts across desktop tools so that, by default, the same action had the same shortcut, regardless of where it was triggered. However, I knew that making such a change would introduce backwards incompatibilities and possibly annoy existing MATLAB users, so I wanted to ensure that flexibility existed for customers to achieve exactly the same hybrid configurations that we previously supported. At the same time, this flexibility could not be burdensome to users who desired to quickly change a keyboard shortcut across the desktop, without dealing with individual tools.</p>
<p>So now let’s take a look at the solution that I developed, using the Ctrl+A example discussed above. First, compare the Ctrl+A assignments in the new Windows Default Set to the assignments in the legacy R2009a set.</p>
<div align="center">
<b>New Windows Default Set as of R2009b</b><br />
<img border="0" src="http://blogs.mathworks.com/images/desktop/christina_roberts_keyboard_shortcuts_history/select_all.png">
</div>
<p><br/></p>
<div align="center">
<b>Old Windows Default Set as of R2009a</b><br />
<img border="0" src="http://blogs.mathworks.com/images/desktop/christina_roberts_keyboard_shortcuts_history/cursor_begin_line.png">
</div>
<p>In R2009a on Windows, Ctrl+A was not assigned to <em>Select All</em> in the Command Window, and instead had the Emacs-based assignment of <em>Cursor Begin Line</em>. Now, let’s assume that you are an existing MATLAB user and you have Ctrl+A committed in your muscle memory to going to the beginning of the line. You have 2 options—you can revert back to the legacy R2009a Windows Default Set, or you can modify the <em>Select All</em> and <em>Cursor Begin Line</em> assignments in the new default set.</p>
<p>Modifying the new default set is a far better long term solution if there are a relatively small number of keyboard shortcuts that are bothering you. If you stick with our new default sets, as new actions and tools are added to the desktop, you will automatically obtain their keyboard shortcuts—this is because we only store the customizations (differences) that you have made from our shipping defaults. In contrast, the legacy sets are complete listings of exactly what we had in release R2009a, and they will not evolve with new features.</p>
<p>So let’s change the assignments related to Ctrl+A in the new Windows Default Set. To do this, first click on <em>Select All</em> and then un-assign the Command Window from the list of tools with the Ctrl+A shortcut.</p>
<div align="center">
<img border="0" src="http://blogs.mathworks.com/images/desktop/christina_roberts_keyboard_shortcuts_history/select_all_change.png">
</div>
<p>Then select <em>Cursor Begin Line</em>, press the <img border="0" src="http://blogs.mathworks.com/images/desktop/christina_roberts_keyboard_shortcuts_history/plus.png"> button, and add a new shortcut of Ctrl+A to the Command Window only.</p>
<div align="center">
<img border="0" src="http://blogs.mathworks.com/images/desktop/christina_roberts_keyboard_shortcuts_history/cursor_begin_line_change.png">
</div>
<p>If you now search for Ctrl+A in the table of actions, and you will see that the assignments match the ones in R2009a.</p>
<div align="center">
<img border="0" src="http://blogs.mathworks.com/images/desktop/christina_roberts_keyboard_shortcuts_history/ctrl_a.png">
</div>
<p>That is a quick summary of how the new customizable keyboard shortcuts were developed. I hope that you find this feature useful, and I’d love to hear your feedback!</p>
<p><i>-by Christina Roberts, The MathWorks</i></p>
<img src="http://feeds.feedburner.com/~r/mathworks/desktop/~4/cGBL9jjwVeQ" height="1" width="1"/>]]></content:encoded>
      </item>
      <item>
         <title>Deploying Image Processing Toolbox apps in R2009b - we goofed</title>
         <link>http://feedproxy.google.com/~r/SteveOnImageProcessing/~3/b1JAZEKBwyQ/</link>
         <description>Ack! We discovered recently that we broke application deployment when using the MATLAB Compiler with Image Processing Toolbox functions in R2009b. The problem happens only on Windows and is caused by some missing shared libraries in the deployed application. If you use the R2009b MATLAB Compiler on Windows with the Image Processing Toolbox, please see our published [...]</description>
         <guid isPermaLink="false">http://blogs.mathworks.com/steve/2009/10/12/deploying-image-processing-toolbox-apps-in-r2009b-we-goofed/</guid>
         <pubDate>Mon, 12 Oct 2009 00:00:38 -0700</pubDate>
         <content:encoded><![CDATA[<p>
Ack!
</p> <p>
We discovered recently that we broke application deployment when using the <a rel="nofollow" target="_blank" href="http://www.mathworks.com/products/compiler/">MATLAB Compiler</a> with Image Processing Toolbox functions in R2009b. The problem happens only on Windows and is caused by some missing shared libraries in the deployed application.
</p> <p>
If you use the R2009b MATLAB Compiler on Windows with the Image Processing Toolbox, please see our <a rel="nofollow" target="_blank" href="http://www.mathworks.com/support/bugreports/581700">published bug report</a> for a workaround. (Note: there is <strong>no need</strong> to apply this workaround to earlier releases.)
</p> <p>
We are reviewing our procedures to try to make sure something like this doesn't happen again.
</p><img src="http://feeds.feedburner.com/~r/SteveOnImageProcessing/~4/b1JAZEKBwyQ" height="1" width="1"/>]]></content:encoded>
         <category>Uncategorized</category>
      </item>
      <item>
         <title>Handling Discrete Data</title>
         <link>http://feedproxy.google.com/~r/mathworks/loren/~3/D0RplIr36fY/</link>
         <description>Discrete data arise in many applications and the data may be numeric, or non-numeric, often referred to as categorical. Not all data are strictly numeric, and other characteristics can be pertinent or useful. You can use a variety [...]</description>
         <guid isPermaLink="false">http://blogs.mathworks.com/loren/2009/10/09/handling-discrete-data/</guid>
         <pubDate>Fri, 09 Oct 2009 08:46:08 -0700</pubDate>
         <content:encoded><![CDATA[<div class="content"><p>Discrete data arise in many applications and the data may be numeric, or non-numeric, often referred to as categorical. Not all data are strictly numeric, and other characteristics can be pertinent or useful. You can use a variety of techniques and data representations in MATLAB for storing and manipulation discrete data. </p>  <h3>Contents</h3> <div> <ul> <li><a rel="nofollow" href="#1">Example: Periodic Table of Elements</a></li> <li><a rel="nofollow" href="#3">Discrete Data Representation Options</a></li> <li><a rel="nofollow" href="#4">logical</a></li> <li><a rel="nofollow" href="#5">String or Coded Integer</a></li> <li><a rel="nofollow" href="#8">nominal Array</a></li> <li><a rel="nofollow" href="#12">ordinal Array</a></li> <li><a rel="nofollow" href="#16">Integer</a></li> <li><a rel="nofollow" href="#17">Going All the Way</a></li> <li><a rel="nofollow" href="#18">Your Data or Experiment</a></li> </ul> </div> <h3>Example: Periodic Table of Elements<a rel="nofollow" name="1"></a></h3> <p><a rel="nofollow" target="_blank" href="http://en.wikipedia.org/wiki/Periodic_table">The periodic table of elements</a> provides a rich basis for this discussion. If you remember your chemistry class (I did, very imperfectly), you probably remember that each element has a fixed number of protons associated with it, also called the atomic number. You might also remember that the periodic table is arranged so that certain columns of elements have certain characteristics. For example, apart from Hydrogen, the left-most column holds the alkali metals (such as sodium and potassium) and the left side generally contains metallic elements. The right-most column holds Noble gases, with the next column to their left holding halogens. Nonmetals are towards the right side of the table. At standard temperature and pressure (known as STP), elements are in one of three states: solid, liquid, or gas. </p> <p>We've just talked about 3 different things:</p> atomic number (number of protons in the nucleus), positive integers and therefore numeric solid, liquid, gas states, which can be considered ordinal (that is, solid &lt; liquid &lt; gas) element categories include the metals, nonmetals, etc., and these are simply labels or names, and therefore nominal (notice how these categories aren't strictly columnar in the periodic table)  <h3>Discrete Data Representation Options<a rel="nofollow" name="3"></a></h3> <p>I will try to use the periodic table example for each of the possible discrete data representations, but some of these will be forced examples. </p> <h3>logical<a rel="nofollow" name="4"></a></h3> <p>You could imagine use a <a rel="nofollow" target="_blank" href="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/logical.html"><tt>logical</tt></a> variable to indicate elements that are in the Noble category as <tt>true</tt> and <tt>false</tt> for the remainder. </p> <h3>String or Coded Integer<a rel="nofollow" name="5"></a></h3> <p><tt>logical</tt> variables are fine if you are representing exactly two possible categories. However, looking at the periodic table, you see that I collapsed a subset of categories into "not Noble" (<tt>false</tt>). Rather than collapsing the set of categories into Noble and not Noble, the entire collection might be better represented as integers that are arbitrarily given meaning, or by strings. For example, I could code alkali metals as <tt>'alkali metals'</tt> or as <tt>1</tt>, and so on. The first 3 elements of the table would be represented with <tt>[8 10 1]</tt> or as <tt>{'other nonmetals' 'noble gases' 'alkali metals'}</tt>. </p> <p>Coded integers are useful for doing comparisons, for example, subsetting the data, and are memory-efficient. However, integers can cause you some mental overhead trying to remember the mapping between them and their labels. </p> <p>Strings are good for representing the data in a readable form, but are harder to manipulate, especially for an ordered list such as phase states. Also you may prefer to use numeric type operations such as <tt>==</tt>, <tt>~=</tt>, and <tt>&lt;</tt> since they are more direct and show intent. In addition, strings take more memory, especially when your data comprise many repetitions of the same value. </p> <h3>nominal Array<a rel="nofollow" name="8"></a></h3> <p>You have additional choices with <a rel="nofollow" target="_blank" href="http://www.mathworks.com/access/helpdesk/help/toolbox/stats/nominal.html"><tt>nominal</tt></a> and <a rel="nofollow" target="_blank" href="http://www.mathworks.com/access/helpdesk/help/toolbox/stats/ordinal.html"><tt>ordinal</tt></a> arrays from <a rel="nofollow" target="_blank" href="http://www.mathworks.com/products/statistics/">Statistics Toolbox</a>. </p> <p>Let's imagine that we create an array representing the element categories by atomic number. The first 10 elements of this array look like this. I collapse some of the traditional categories for brevity. </p><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);">catLabels = {<span style="color:#A020F0;">'metals'</span>, <span style="color:#A020F0;">'metalloids'</span>,<span style="color:#A020F0;">'other nonmetals'</span>,<span style="color:#A020F0;">'halogens'</span>, <span style="color:#0000FF;">...</span> <span style="color:#A020F0;">'noble gases'</span>, <span style="color:#A020F0;">'unknown'</span>};
elemCats = nominal([3 5 1 1 2 3 3 3 4 5]', catLabels, 1:length(catLabels))
elemNames = {<span style="color:#A020F0;">'hydrogen'</span>,<span style="color:#A020F0;">'helium'</span>,<span style="color:#A020F0;">'lithium'</span>,<span style="color:#A020F0;">'beryllium'</span>,<span style="color:#A020F0;">'boron'</span>, <span style="color:#0000FF;">...</span> <span style="color:#A020F0;">'carbon'</span>,<span style="color:#A020F0;">'nitrogen'</span>,<span style="color:#A020F0;">'oxygen'</span>,<span style="color:#A020F0;">'fluorine'</span>,<span style="color:#A020F0;">'neon'</span>}';</pre><pre style="font-style:oblique;">elemCats = other nonmetals noble gases metals metals metalloids other nonmetals other nonmetals other nonmetals halogens noble gases </pre><p>Here is the list of all possible values for the categories. Notice that this nominal array carries that information with it. (You can modify this by adding, renaming, and deleting as necessary.) </p><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);">getlabels(elemCats)</pre><pre style="font-style:oblique;">ans = Columns 1 through 5 'metals' 'metalloids' 'other nonmetals' 'halogens' 'noble gases' Column 6 'unknown'
</pre><p>Let's find all the 'other nonmetals' in the list.</p><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);">nonmets = find(elemCats == <span style="color:#A020F0;">'other nonmetals'</span>)
elemNames(nonmets)</pre><pre style="font-style:oblique;">nonmets = 1 6 7 8
ans = 'hydrogen' 'carbon' 'nitrogen' 'oxygen'
</pre><h3>ordinal Array<a rel="nofollow" name="12"></a></h3> <p>Let's investigate the states of the first 10 elements now. For some purposes, the states can be regarded as nominal. However, they can also be viewed as an ordered set, <tt>solid &lt; liquid &lt; gas</tt>. (At STP, only mercury and bromine are in liquid state.) </p><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);">stLabels = {<span style="color:#A020F0;">'solid'</span> <span style="color:#A020F0;">'liquid'</span> <span style="color:#A020F0;">'gas'</span>};
elemSts = ordinal([3 3 1 1 1 1 3 3 3 3]', stLabels, 1:length(stLabels))</pre><pre style="font-style:oblique;">elemSts = gas gas solid solid solid solid gas gas gas gas </pre><p>Here is the list of all possible values for the states.</p><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);">getlabels(elemSts)</pre><pre style="font-style:oblique;">ans = 'solid' 'liquid' 'gas'
</pre><p>Let's find all the gases in the list.</p><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);">gases = find(elemSts &gt; <span style="color:#A020F0;">'liquid'</span>) <span style="color:#228B22;">% or == 'gas'</span>
elemNames(gases)</pre><pre style="font-style:oblique;">gases = 1 2 7 8 9 10
ans = 'hydrogen' 'helium' 'nitrogen' 'oxygen' 'fluorine' 'neon'
</pre><p>Let's sort the element list by state.</p><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);">[sts, elemNo] = sort(elemSts)
[cellstr(sts) elemNames(elemNo)]</pre><pre style="font-style:oblique;">sts = solid solid solid solid gas gas gas gas gas gas elemNo = 3 4 5 6 1 2 7 8 9 10
ans = 'solid' 'lithium' 'solid' 'beryllium' 'solid' 'boron' 'solid' 'carbon' 'gas' 'hydrogen' 'gas' 'helium' 'gas' 'nitrogen' 'gas' 'oxygen' 'gas' 'fluorine' 'gas' 'neon' </pre><h3>Integer<a rel="nofollow" name="16"></a></h3> <p>For the given list of elements, the atomic number happens to match exactly with the index into the <tt>elemNames</tt> array. So I only need to create the relevant integer values 1:10 to represent the atomic number. This list is itself clearly ordered, and has numerical meaning (unlike <tt>ordinal</tt> arrays which are ordered but the spacing between elements has no definition). </p> <h3>Going All the Way<a rel="nofollow" name="17"></a></h3> <p>To continue this example, you can collect all the information together into a single <a rel="nofollow" target="_blank" href="http://www.mathworks.com/access/helpdesk/help/toolbox/stats/datasetclass.html"><tt>dataset</tt></a> array (from Statistics Toolbox). The advantages include being able to "index" by the element name! </p><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);">atomicNo = (1:length(elemNames))';
periodicTable = dataset(atomicNo ,elemCats, elemSts, <span style="color:#A020F0;">'obsnames'</span>, elemNames)</pre><pre style="font-style:oblique;">periodicTable = atomicNo elemCats elemSts hydrogen 1 other nonmetals gas helium 2 noble gases gas lithium 3 metals solid beryllium 4 metals solid boron 5 metalloids solid carbon 6 other nonmetals solid nitrogen 7 other nonmetals gas oxygen 8 other nonmetals gas fluorine 9 halogens gas neon 10 noble gases gas </pre><h3>Your Data or Experiment<a rel="nofollow" name="18"></a></h3> <p>Do you have a situation where some of your data can be represented with <tt>nominal</tt> or <tt>ordinal</tt> arrays? How do you manage that information now? Let me know by posting <a rel="nofollow" target="_blank" href="http://blogs.mathworks.com/loren/?p=201#respond">here</a>. </p><p style="text-align:right;font-size:xx-small;font-weight:lighter;font-style:italic;color:gray;"><br /><a rel="nofollow"><span style="font-size:x-small;font-style:italic;">Get the MATLAB code <noscript>(requires JavaScript)</noscript></span></a><br /><br /> Published with MATLAB&reg; 7.9<br /></p>
</div>
<img src="http://feeds.feedburner.com/~r/mathworks/loren/~4/D0RplIr36fY" height="1" width="1"/>]]></content:encoded>
      </item>
      <item>
         <title>Colored Area on a Curved Surface</title>
         <link>http://feedproxy.google.com/~r/mathworks/pick/~3/-BcqmsbaRko/</link>
         <description>Bob's pick this week is Colored Area on a Curved Surface by Michael Wunder. This is a nice example of quantitative image analysis. Given a heat map and region of interest based on elevation, [...]</description>
         <guid isPermaLink="false">http://blogs.mathworks.com/pick/2009/10/09/colored-area-on-a-curved-surface/</guid>
         <pubDate>Fri, 09 Oct 2009 06:32:51 -0700</pubDate>
         <content:encoded><![CDATA[<div class="content"><p><a rel="nofollow" target="_blank" href="http://www.mathworks.com/matlabcentral/fileexchange/authors/5021">Bob</a>'s pick this week is <a rel="nofollow" target="_blank" href="http://www.mathworks.com/matlabcentral/fileexchange/5726">Colored Area on a Curved Surface</a> by Michael Wunder. </p>  <p>This is a nice example of quantitative image analysis. Given a heat map and region of interest based on elevation,</p> <p><img vspace="5" hspace="5" src="http://www.mathworks.com/matlabcentral/fx_files/5726/1/content/ColorArea_01.png"> </p> <p>compute the surface area.</p> <p><img vspace="5" hspace="5" src="http://www.mathworks.com/matlabcentral/fx_files/5726/1/content/ColorArea_04.png"> </p> <p>See Michael's <a rel="nofollow" target="_blank" href="http://www.mathworks.com/matlabcentral/fx_files/5726/1/content/ColorArea.html">published example</a> for the step by step details. </p> <p><a rel="nofollow" target="_blank" href="http://blogs.mathworks.com/pick/?p=2481#respond">Comments?</a></p><p style="text-align:right;font-size:xx-small;font-weight:lighter;font-style:italic;color:gray;"><br /><a rel="nofollow"><span style="font-size:x-small;font-style:italic;">Get the MATLAB code <noscript>(requires JavaScript)</noscript></span></a><br /><br /> Published with MATLAB&reg; 7.10<br /></p>
</div>
<img src="http://feeds.feedburner.com/~r/mathworks/pick/~4/-BcqmsbaRko" height="1" width="1"/>]]></content:encoded>
         <category>Picks</category>
      </item>
      <item>
         <title>Midweek update: MATLAB Virtual Conference next week October 14th</title>
         <link>http://feedproxy.google.com/~r/mathworks/desktop/~3/kyGSJ9Mcgyo/</link>
         <description>MathWorks is hosting a MATLAB virtual conference on Wednesday, October 14. It&amp;#8217;ll basically be like a regular conference but all the events, meetings, booths, etc will be online. Conference Info Page
Register
Presentation Schedule I will be facilitating forum discussions on MATLAB tips and tricks from 2-3pm and 4-5pm (Eastern). Fellow bloggers Loren and Jiro will also be [...]</description>
         <guid isPermaLink="false">http://blogs.mathworks.com/desktop/2009/10/08/midweek-update-matlab-virtual-conference-next-week-october-14th/</guid>
         <pubDate>Thu, 08 Oct 2009 13:22:11 -0700</pubDate>
         <content:encoded><![CDATA[<p>MathWorks is hosting a MATLAB virtual conference on Wednesday, October 14. It&#8217;ll basically be like a regular conference but all the events, meetings, booths, etc will be online. </p>
<ul>
<li><a rel="nofollow" target="_blank" href="http://events.unisfair.com/index.jsp?eid=461">Conference Info Page</a></li>
<li><a rel="nofollow" target="_blank" href="http://events.unisfair.com/index.jsp?eid=461">Register</a></li>
<li><a rel="nofollow" target="_blank" href="http://events.unisfair.com/microsite24.jsp?eid=461&#038;seid=56&#038;language-code=en&#038;country-code=US&#038;page=1250096730240">Presentation Schedule</a></li>
</ul>
<p>I will be facilitating forum discussions on MATLAB tips and tricks from 2-3pm and 4-5pm (Eastern). Fellow bloggers <a rel="nofollow" target="_blank" href="http://blogs.mathworks.com/loren">Loren</a> and <a rel="nofollow" target="_blank" href="http://blogs.mathworks.com/pick/">Jiro</a> will also be hosting forum discussions.</p>
<img src="http://feeds.feedburner.com/~r/mathworks/desktop/~4/kyGSJ9Mcgyo" height="1" width="1"/>]]></content:encoded>
         <category>Uncategorized</category>
      </item>
      <item>
         <title>MathWorks Hosts EcoCAR</title>
         <link>http://feedproxy.google.com/~r/SethOnSimulink/~3/sMBDICbHIuA/</link>
         <description>Recently, when I arrived at work, I found this parked on the
lawn: This is the EcoCAR from the EcoCAR Challenge. MathWorks hosted
about one hundred students from the EcoCAR teams for the EcoCAR Year 2 Fall
Workshop. A Big Shiny Embedded Target When I first saw the EcoCAR sitting on the lawn, I wondered
what system target file they might use: I’m [...]</description>
         <guid isPermaLink="false">http://blogs.mathworks.com/seth/2009/10/06/mathworks-hosts-eco-car/</guid>
         <pubDate>Mon, 05 Oct 2009 20:00:21 -0700</pubDate>
         <content:encoded><![CDATA[<p>Recently, when I arrived at work, I found this parked on the
lawn:</p> <p><img src="http://blogs.mathworks.com/images/seth/2009Q4/EcoCar_onLawnSmall.jpg" alt="EcoCAR Chalenge Year 2 Fall Workshop at The MathWorks"></p> <p>This is the EcoCAR from the <a rel="nofollow"
 target="_blank" href="http://www.ecocarchallenge.org/">EcoCAR Challenge</a>. MathWorks hosted
about one hundred students from the EcoCAR teams for the EcoCAR Year 2 Fall
Workshop.</p> <p><strong>A Big Shiny Embedded Target</strong></p> <p>When I first saw the EcoCAR sitting on the lawn, I wondered
what system target file they might use:</p> <p><img src="http://blogs.mathworks.com/images/seth/2009Q4/EcoCarTLC_small.png" alt="An imaginary EcoCAR System TLC file."></p> <p>I’m sure there are a lot of cool things these students will
be able to do with a great piece of hardware like this, but in many ways, it’s
just a big, shinny embedded target.</p> <p><strong>What is EcoCAR?</strong></p> <p>EcoCAR is an academic competition. A quote from <a rel="nofollow"
 target="_blank" href="http://www.ecocarchallenge.org/about_ecocar.html">ecocarchallenge.org</a>
sums it up:</p> <p> “The competition challenges 17 universities across North America to reduce the environmental impact of vehicles by minimizing the vehicle’s fuel consumption and reducing its emissions while retaining the vehicle’s performance, safety and consumer appeal. Students use a real-world engineering process to design and integrate their advanced technology solutions
into a 2009 Saturn Vue.”</p> <p>The students had 5 days of training in different tracks to
learn and apply MathWorks tools to the design problems facing them. If you
read the <a rel="nofollow" target="_blank" href="http://greengarageblog.org/">Green Car Garage blog</a>, you
may have read about <a rel="nofollow"
 target="_blank" href="http://greengarageblog.org/2009/09/23/the-mathworks-welcomes-future-automotive-engineers/">the
event</a> and <a rel="nofollow"
 target="_blank" href="http://greengarageblog.org/2009/09/24/racing-toward-sustainability-engineers-in-the-loop-eil/">the
fun</a> teams had during their visit to Boston. Nicole Lambiase from <a rel="nofollow"
 target="_blank" href="http://www.anl.gov/">Argon National Lab</a> wrote a <a rel="nofollow"
 target="_blank" href="http://greengarageblog.org/2009/10/02/switching-gears-reflections-on-the-fall-workshop-from-student-turned-organize">post
commenting</a> that it really takes a village to make these competition events
run smoothly. Some of the people in that village are members of the
Model-Based Design community. A lot of my colleagues volunteer with EcoCAR
Challenge. Many of them traveled from our Michigan office to lead trainings
and mentor students that attended. </p> <p><strong>The Trouble with Model-Based Design</strong></p> <p>The trouble with Model-Based Design is that there are very
few people and institutions available to help you learn it. I never had a
class on Model-Based Design when I went to school. The EcoCAR Challenge is an opportunity
to develop the next generation of engineers skilled in Model-Based Design. MathWorks
is very committed to mentoring these future engineers. This aligns with our academic
mission to accelerate the pace of learning, discovery, and research in
engineering and science.</p> <p><strong>How about you?</strong></p> <p>How did you learn about modeling and Model-Based Design? Who
was your mentor? Leave a <a rel="nofollow"
 target="_blank" href="http://blogs.mathworks.com/seth/?p=68&amp;#comment">comment here</a> and
share your story.</p><img src="http://feeds.feedburner.com/~r/SethOnSimulink/~4/sMBDICbHIuA" height="1" width="1"/>]]></content:encoded>
      </item>
      <item>
         <title>October 14 - Virtual MATLAB Conference</title>
         <link>http://feedproxy.google.com/~r/mathworks/loren/~3/kTP1vroi-PU/</link>
         <description>We're having a MATLAB conference on October 14, in the virtual world. There'll be presentations, forums, chats, live discussion, etc. Please check out the event and join in the fun! Here's the presentation schedule to help you find what you'd like to participate in. I'm planning to attend some of the forums [...]</description>
         <guid isPermaLink="false">http://blogs.mathworks.com/loren/2009/10/05/october-14-virtual-matlab-conference/</guid>
         <pubDate>Mon, 05 Oct 2009 06:35:23 -0700</pubDate>
         <content:encoded><![CDATA[We're having a MATLAB conference on October 14, in the virtual world. There'll be presentations, forums, chats, live discussion, etc. Please check out the event and <a rel="nofollow" target="_blank" href="http://events.unisfair.com/rt/matlab%7Evirtualconf?code=hp-listing">join</a> in the fun!
 <p> </p> <p> Here's the <a rel="nofollow" target="_blank" href="http://events.unisfair.com/microsite24.jsp?eid=461&amp;seid=56&amp;language-code=en&amp;country-code=US&amp;page=1250096730240">presentation schedule</a> to help you find what you'd like to participate in.
</p> <p> I'm planning to attend some of the forums and listen to many of the talks, including ones focused on MATLAB for education. Hope to meet you there!
</p>
<img src="http://feeds.feedburner.com/~r/mathworks/loren/~4/kTP1vroi-PU" height="1" width="1"/>]]></content:encoded>
         <category>Education</category>
      </item>
      <item>
         <title>Slimming down the Help browser</title>
         <link>http://feedproxy.google.com/~r/mathworks/desktop/~3/fyEB3F6wXJk/</link>
         <description>I&amp;#8217;d like to welcome guest blogger Chris Kollett this week from the MATLAB Help team to talk about the redesigned Help Browser. If you&amp;#8217;re a regular user of the Help browser, you&amp;#8217;ll notice that its user interface has changed quite a bit in R2009b. One of our main motivations for these changes was to make [...]</description>
         <guid isPermaLink="false">http://blogs.mathworks.com/desktop/2009/10/05/slimming-down-the-help-browser/</guid>
         <pubDate>Mon, 05 Oct 2009 05:17:51 -0700</pubDate>
         <content:encoded><![CDATA[<p><i><br />
I&#8217;d like to welcome guest blogger Chris Kollett this week from the MATLAB Help team to talk about the redesigned Help Browser.<br />
</i></p>
<p>If you&#8217;re a regular user of the Help browser, you&#8217;ll notice that its user interface has changed quite a bit in R2009b. One of our main motivations for these changes was to make the Help browser useful in layouts other than its default layout. Time and time again we&#8217;ve seen users struggle to use the Editor and Help browser at the same time, because they both work best when they&#8217;re laid out relatively wide. Since users can&#8217;t get them both on screen at the same time, they end up switching back and forth between them, wasting time and breaking their flow.</p>
<p>If you struggle to see your work and use the Help system at the same time, here are a couple of tips for making the Help browser take up less space in R2009b:</p>
<p><strong>Close the Help navigator</strong></p>
<p>Yes, really, close the Help navigator (the left side of the Help browser, where the table of contents and the search results show up). It used to be that if you closed the Help navigator you wouldn&#8217;t be able to navigate the doc at all - the table of contents, demos, and even the search field would go away with it. In R2009b, we&#8217;ve moved the search field up into the toolbar when the Help navigator is closed, and even more significantly, we&#8217;ve replaced the old location dropdown with a breadcrumb navigation widget that lets you access to the full table of contents and all of the demos from the toolbar. If you&#8217;ve always wanted the Help browser to give more space to the documentation without sacrificing so much functionality, R2009b should be a big improvement for you.</p>
<div align="center" style="margin:10px;"><a rel="nofollow" target="_blank" href='http://blogs.mathworks.com/desktop/../images/desktop/help_breadcrumb.PNG' title='R2009b Help Browser Breadcrumb Navigation'><img src='http://blogs.mathworks.com/desktop/../images/desktop/help_breadcrumb.PNG' alt='R2009b Help Browser Breadcrumb Navigation' width="90%"/></a></div>
<p><strong>Consider a taller, narrower Help browser</strong></p>
<p>Prior to R2009b, it was virtually impossible to use the Help browser once you made it narrow. The Help navigator could only be positioned on the left hand side of the Help browser, and as we discussed above, you lost a ton of functionality if you tried to close it. So if you made the Help browser narrow, you had very little room left to display the documentation. In R2009b, we&#8217;ve introduced an alternate layout for the Help browser: if you resize the Help browser so that it&#8217;s tall and narrow, the Help navigator moves up above the contents. We&#8217;re hoping you&#8217;ll find it convenient to try some alternate layouts, like docking the Help browser in a narrow space next to the editor.</p>
<div align="center" style="margin:10px;"><a rel="nofollow" target="_blank" href='http://blogs.mathworks.com/desktop/../images/desktop/help_stacked.png' title='R2009b Help Browser Narrow Layout'><img src='http://blogs.mathworks.com/desktop/../images/desktop/help_stacked.png' alt='R2009b Help Browser Narrow Layout'/></a></div>
<p>Please try out these changes and let us know if they help keep you in your flow - we don’t want you to get bogged down in the Help browser and lose track of your work. We’ll look at some other changes to the Help browser in a later entry.</p>
<img src="http://feeds.feedburner.com/~r/mathworks/desktop/~4/fyEB3F6wXJk" height="1" width="1"/>]]></content:encoded>
         <category>Help Browser</category>
      </item>
      <item>
         <title>Using parfor Loops: Getting Up and Running</title>
         <link>http://feedproxy.google.com/~r/mathworks/loren/~3/7cUnXauqT9Y/</link>
         <description>Today I&amp;#8217;d like to introduce a guest blogger, Sarah Wait Zaranek, who is an application engineer here at The MathWorks. Sarah previously has written about speeding up code from a customer to get acceptable performance. She again will be writing about speeding up MATLAB [...]</description>
         <guid isPermaLink="false">http://blogs.mathworks.com/loren/2009/10/02/using-parfor-loops-getting-up-and-running/</guid>
         <pubDate>Fri, 02 Oct 2009 09:30:13 -0700</pubDate>
         <content:encoded><![CDATA[<div class="content"><p>Today I&#8217;d like to introduce a guest blogger, <a rel="nofollow" target="_blank" href="mailto:sarah.zaranek@mathworks.com">Sarah Wait Zaranek</a>, who is an application engineer here at The MathWorks. Sarah previously has <a rel="nofollow" target="_blank" href="http://blogs.mathworks.com/loren/2008/06/25/speeding-up-matlab-applications/">written</a> about speeding up code from a customer to get acceptable performance. She again will be writing about speeding up MATLAB applications, but this time her focus will be on using the parallel computing tools. </p>  <h3>Contents</h3> <div> <ul> <li><a rel="nofollow" href="#1">Introduction</a></li> <li><a rel="nofollow" href="#2">Method</a></li> <li><a rel="nofollow" href="#4">Background on parfor-loops</a></li> <li><a rel="nofollow" href="#5">Opening the matlabpool</a></li> <li><a rel="nofollow" href="#8">Independence</a></li> <li><a rel="nofollow" href="#11">Globals and Transparency</a></li> <li><a rel="nofollow" href="#12">Classification</a></li> <li><a rel="nofollow" href="#21">Uniqueness</a></li> <li><a rel="nofollow" href="#28">Your examples</a></li> </ul> </div> <h3>Introduction<a rel="nofollow" name="1"></a></h3> <p>I wanted to write a post to help users better understand our parallel computing tools. In this post, I will focus on one of the more commonly used functions in these tools: the <tt>parfor</tt>-loop. </p> <p>This post will focus on getting a parallel code using <tt>parfor</tt> up and running. Performance will not be addressed in this post. I will assume that the reader has a basic knowledge of the <tt>parfor</tt>-loop construct. Loren has a very nice introduction to using <tt>parfor</tt> in one of her previous <a rel="nofollow" target="_blank" href="http://blogs.mathworks.com/loren/2007/10/03/parfor-the-course/">posts</a>. There are also some nice introductory <a rel="nofollow" target="_blank" href="http://www.mathworks.com/products/parallel-computing/demos.html">videos</a>. </p> <p><i>Note for clarity</i> : Since Loren's introductory post, the toolbox used for parallel computing has changed names from the Distributed Computing Toolbox to the <a rel="nofollow" target="_blank" href="http://www.mathworks.com/products/parallel-computing/">Parallel Computing Toolbox</a>. These are not two separate toolboxes. </p> <h3>Method<a rel="nofollow" name="2"></a></h3> <p>In some cases, you may only need to change a <tt>for</tt>-loop to a <tt>parfor</tt>-loop to get their code running in parallel. However, in other cases you may need to slightly alter the code so that <tt>parfor</tt> can work. I decided to show a few examples highlighting the main challenges that one might encounter. I have separated these examples into four encompassing categories: </p> <div> <ul> <li>Independence</li> <li>Globals and Transparency</li> <li>Classification</li> <li>Uniqueness</li> </ul> </div> <h3>Background on parfor-loops<a rel="nofollow" name="4"></a></h3> <p>In a <tt>parfor</tt>-loop (just like in a standard <tt>for</tt>-loop) a series of statements known as the loop body are iterated over a range of values. However, when using a <tt>parfor</tt>-loop the iterations are run not on the client MATLAB machine but are run in parallel on MATLAB workers. </p> <p>Each worker has its own unique workspace. So, the data needed to do these calculations is sent from the client to workers, and the results are sent back to the client and pieced together. The cool thing about <tt>parfor</tt> is this data transfer is handled for the user. When MATLAB gets to the <tt>parfor</tt>-loop, it statically analyzes the body of the <tt>parfor</tt>-loop and determines what information goes to which worker and what variables will be returning to the client MATLAB. Understanding this concept will become important when understanding why particular constraints are placed on the use of <tt>parfor</tt>. </p> <h3>Opening the matlabpool<a rel="nofollow" name="5"></a></h3> <p>Before looking at some examples, I will open up a matlabpool so I can run my loops in parallel. I will be opening up the matlabpool using my default local configuration (i.e. my workers will be running on the dual-core laptop machine where my MATLAB has been installed). </p><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);"><span style="color:#0000FF;">if</span> matlabpool(<span style="color:#A020F0;">'size'</span>) == 0 <span style="color:#228B22;">% checking to see if my pool is already open</span> matlabpool <span style="color:#A020F0;">open</span> <span style="color:#A020F0;">2</span>
<span style="color:#0000FF;">end</span></pre><pre style="font-style:oblique;">Starting matlabpool using the 'local' configuration ... connected to 2 labs.
</pre><p><i>Note</i> : The <tt>'size'</tt> option was new in R2008b. </p> <h3>Independence<a rel="nofollow" name="8"></a></h3> <p>The <tt>parfor</tt>-loop is designed for task-parallel types of problems where each iteration of the loop is independent of each other iteration. This is a critical requirement for using a <tt>parfor</tt>-loop. Let's see an example of when each iteration is not independent. </p><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);">type <span style="color:#A020F0;">dependentLoop.m</span></pre><pre style="font-style:oblique;">
% Example of a dependent for-loop
a = zeros(1,10); parfor it = 1:10 a(it) = someFunction(a(it-1));
end
</pre><p>Checking the above code using M-Lint (MATLAB's static code analyzer) gives a warning message that these iterations are dependent and will not work with the <tt>parfor</tt> construct. M-Lint can either be accessed via the editor or command line. In this case, I use the command line and have defined a simple function <tt>displayMlint</tt> so that the display is compact. </p><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);">output = mlint(<span style="color:#A020F0;">'dependentLoop.m'</span>);
displayMlint(output)</pre><pre style="font-style:oblique;">The PARFOR loop cannot run due to the way variable 'a' is used. In a PARFOR loop, variable 'a' is indexed in different ways, potentially causing dependencies between iterations. </pre><p>Sometimes loops are intrinsically or unavoidably dependent, and therefore <tt>parfor</tt> is not a good fit for that type of calculation. However, in some cases it is possible to reformulate the body of the loop to eliminate the dependency or separate it from the main time-consuming calculation. </p> <h3>Globals and Transparency<a rel="nofollow" name="11"></a></h3> <p>All variables within the body of a <tt>parfor</tt>-loop must be transparent. This means that all references to variables must occur in the text of the program. Since MATLAB is statically analyzing the loops to figure out what data goes to what worker and what data comes back, this seems like an understandable restriction. </p> <p>Therefore, the following commands cannot be used within the body of a <tt>parfor</tt>-loop : <tt>evalc</tt>, <tt>eval</tt>, <tt>evalin</tt>, and <tt>assignin</tt>. <tt>load</tt> can also not be used unless the output of load is <a rel="nofollow" target="_blank" href="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/load.html">assigned</a> to a variable name. It is possible to use the above functions within a function called by <tt>parfor</tt>, due to the fact that the function has its own workspace. I have found that this is often the easiest workaround for the transparency issue. </p> <p>Additionally, you cannot define global variables or persistent variables within the body of the <tt>parfor</tt> loop. I would also suggest being careful with the use of globals since changes in global values on workers are not automatically reflected in local global values. </p> <h3>Classification<a rel="nofollow" name="12"></a></h3> <p>A detailed description of the <a rel="nofollow" target="_blank" href="http://www.mathworks.com/access/helpdesk/help/toolbox/distcomp/index.html?/access/helpdesk/help/toolbox/distcomp/brdqtjj-1.html">classification</a> of variables in a <tt>parfor</tt>-loop is in the documentation. I think it is useful to view classification as representing the different ways a variable is passed between client and worker and the different ways it is used within the body of the <tt>parfor</tt>-loop. </p> <p><i>Challenges with Classification</i></p> <p>Often challenges arise when first converting <tt>for</tt>-loops to <tt>parfor</tt>-loops due to issues with this classification. An often seen issue is the conversion of nested <tt>for</tt>-loops, where sliced variables are not indexed appropriately. </p> <p>Sliced variables are variables where each worker is calculating on a different part of that variable. Therefore, sliced variables are sliced or divided amongst the workers. Sliced variables are used to prevent unneeded data transfer from client to worker. </p> <p><i>Using <tt>parfor</tt> with Nested <tt>for</tt>-Loops</i></p> <p>The loop below is nested and encounters some of the restrictions placed on <tt>parfor</tt> for sliced variables. </p><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);">type <span style="color:#A020F0;">parforNestTry.m</span></pre><pre style="font-style:oblique;">
A1 = zeros(10,10); parfor ix = 1:10 for jx = 1:10 A1(ix, jx) = ix + jx; end
end
</pre><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);">output = mlint(<span style="color:#A020F0;">'parforNestTry.m'</span>);
displayMlint(output);</pre><pre style="font-style:oblique;">The PARFOR loop cannot run due to the way variable 'A1' is used. Valid indices for 'A1' are restricted in PARFOR loops. </pre><p>In this case, <tt>A1</tt> is a sliced variable. For sliced variables, the restrictions are placed on the first-level variable indices. This allows <tt>parfor</tt> to easily distribute the right part of the variable to the right workers. </p> <p>The first level indexing ,in general, refers to indexing within the first set of parenthesis or braces. This is <a rel="nofollow" target="_blank" href="http://www.mathworks.com/access/helpdesk/help/toolbox/distcomp/index.html?/access/helpdesk/help/toolbox/distcomp/brdqtjj-1.html">explained</a> in more detail in the same section as classification in the documentation. </p> <p>One of these first-level indices must be the loop counter variable or the counter variable plus or minus a constant. <i>Every other first-level index must be a constant, a non-loop counter variable, a colon, or an <tt>end</tt>.</i></p> <p>In this case, <tt>A1</tt> has an loop counter variable for both first level indices (<tt>ix</tt> and <tt>jx</tt>). </p> <p>The solution to this is make sure a loop counter variable is only one of the indices of <tt>A1</tt> and make the other index a colon. To implement this, the results of the inner loop can be saved to a new variable and then that variable can be saved to the desired variable outside the nested loop. </p><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);">A2 = zeros(10,10); <span style="color:#0000FF;">parfor</span> ix = 1:10 myTemp = zeros(1,10); <span style="color:#0000FF;">for</span> jx = 1:10 myTemp(jx) = ix + jx; <span style="color:#0000FF;">end</span> A2(ix,:) = myTemp;
<span style="color:#0000FF;">end</span></pre><p>You can also solve this issue by using cells. Since <tt>jx</tt> is now in the second level of indexing, it can be an loop counter variable. </p><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);">A3 = cell(10,1); <span style="color:#0000FF;">parfor</span> ix = 1:10 <span style="color:#0000FF;">for</span> jx = 1:10 A3{ix}(jx) = ix + jx; <span style="color:#0000FF;">end</span>
<span style="color:#0000FF;">end</span> A3 = cell2mat(A3);</pre><p>I have found that both solutions have their benefits. While cells may be easier to implement in your code, they also result in <tt>A3</tt> using more memory due to the additional <a rel="nofollow" target="_blank" href="http://www.mathworks.com/access/helpdesk/help/techdoc/matlab_prog/brh72ex-2.html#brh72ex-14">memory</a> requirements for cells. The call to <tt>cell2mat</tt> also adds additional processing time. </p> <p>A similar technique can be used for several levels of nested <tt>for</tt>-loops. </p> <h3>Uniqueness<a rel="nofollow" name="21"></a></h3> <p><i>Doing Machine Specific Calculations</i></p> <p>This is a way, while using <tt>parfor</tt>-loops, to determine which machine you are on and do machine specific instructions within the loop. An example of why you would want to do this is if different machines have data files in different directories, and you wanted to make sure to get into the right directory. Do be careful if you make the code machine-specific since it will be harder to port. </p><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);"><span style="color:#228B22;">% Getting the machine host name</span> [~,hostname] = system(<span style="color:#A020F0;">'hostname'</span>); <span style="color:#228B22;">% If the loop iterations are the same as the size of matlabpool, the</span>
<span style="color:#228B22;">% command is run once per worker.</span> <span style="color:#0000FF;">parfor</span> ix = 1:matlabpool(<span style="color:#A020F0;">'size'</span>) [~,hostnameID{ix}] = system(<span style="color:#A020F0;">'hostname'</span>);
<span style="color:#0000FF;">end</span> <span style="color:#228B22;">% Can then do host/machine specific commands</span>
hostnames = unique(hostnameID);
checkhost = hostnames(1); <span style="color:#0000FF;">parfor</span> ix = 1:matlabpool(<span style="color:#A020F0;">'size'</span>) [~,myhost] = system(<span style="color:#A020F0;">'hostname'</span>); <span style="color:#0000FF;">if</span> strcmp(myhost,checkhost) display(<span style="color:#A020F0;">'On Machine 1'</span>) <span style="color:#0000FF;">else</span> display(<span style="color:#A020F0;">'NOT on Machine 1'</span>) <span style="color:#0000FF;">end</span>
<span style="color:#0000FF;">end</span></pre><pre style="font-style:oblique;">On Machine 1
On Machine 1
</pre><p>In my case since I am running locally -- all of the workers are on the same machine.</p> <p>Here's the same code running on a non-local cluster.</p><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);">matlabpool <span style="color:#A020F0;">close</span>
matlabpool <span style="color:#A020F0;">open</span> <span style="color:#A020F0;">speedy</span>
<span style="color:#0000FF;">parfor</span> ix = 1:matlabpool(<span style="color:#A020F0;">'size'</span>) [~,hostnameID{ix}] = system(<span style="color:#A020F0;">'hostname'</span>);
<span style="color:#0000FF;">end</span> <span style="color:#228B22;">% Can then do host/machine specific commands</span>
hostnames = unique(hostnameID);
checkhost = hostnames(1); <span style="color:#0000FF;">parfor</span> ix = 1:matlabpool(<span style="color:#A020F0;">'size'</span>) [~,myhost] = system(<span style="color:#A020F0;">'hostname'</span>); <span style="color:#0000FF;">if</span> strcmp(myhost,checkhost) display(<span style="color:#A020F0;">'On Machine 1'</span>) <span style="color:#0000FF;">else</span> display(<span style="color:#A020F0;">'NOT on Machine 1'</span>) <span style="color:#0000FF;">end</span>
<span style="color:#0000FF;">end</span></pre><pre style="font-style:oblique;">Sending a stop signal to all the labs ... stopped.
Starting matlabpool using the 'speedy' configuration ... connected to 16 labs.
On Machine 1
On Machine 1
On Machine 1
NOT on Machine 1
On Machine 1
NOT on Machine 1
NOT on Machine 1
NOT on Machine 1
NOT on Machine 1
NOT on Machine 1
NOT on Machine 1
NOT on Machine 1
NOT on Machine 1
NOT on Machine 1
NOT on Machine 1
NOT on Machine 1
</pre><p><i>Note</i>: The <tt>~</tt> feature is new in R2009b and discussed as a new feature in one of Loren's previous blog <a rel="nofollow" target="_blank" href="http://blogs.mathworks.com/loren/2009/09/11/matlab-release-2009b-best-new-feature-or/"> posts</a>. </p> <p><i>Doing Worker Specific Calculations</i></p> <p>I would suggest using the new <tt>spmd</tt> functionality to do worker specific calculations. For more information about <a rel="nofollow" target="_blank" href="http://www.mathworks.com/access/helpdesk/help/toolbox/distcomp/index.html?/access/helpdesk/help/toolbox/distcomp/spmd.html"><tt>spmd</tt></a>, check out the documentation. </p> <p>Clean up</p><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);">matlabpool <span style="color:#A020F0;">close</span></pre><pre style="font-style:oblique;">Sending a stop signal to all the labs ... stopped.
</pre><h3>Your examples<a rel="nofollow" name="28"></a></h3> <p>Tell me about some of the ways you have used <tt>parfor</tt>-loops or feel free to post questions regarding non-performance related issues that haven't been addressed here. Post your questions and thoughts <a rel="nofollow" target="_blank" href="http://blogs.mathworks.com/loren/?p=199#respond">here</a>. </p><p style="text-align:right;font-size:xx-small;font-weight:lighter;font-style:italic;color:gray;"><br /><a rel="nofollow"><span style="font-size:x-small;font-style:italic;">Get the MATLAB code <noscript>(requires JavaScript)</noscript></span></a><br /><br /> Published with MATLAB&reg; 7.9<br /></p>
</div>
<img src="http://feeds.feedburner.com/~r/mathworks/loren/~4/7cUnXauqT9Y" height="1" width="1"/>]]></content:encoded>
      </item>
      <item>
         <title>Integrating the File Exchange with the MATLAB Desktop</title>
         <link>http://feedproxy.google.com/~r/mathworks/pick/~3/ak2h-qApTf4/</link>
         <description>This week's Pick of the Week takes a turn &quot;out of the box&quot;; rather than select a file, I'd like to highlight new functionality in MATLAB that allows one to interface with the MATLAB Central File Exchange directly [...]</description>
         <guid isPermaLink="false">http://blogs.mathworks.com/pick/2009/10/02/integrating-the-file-exchange-with-the-matlab-desktop/</guid>
         <pubDate>Fri, 02 Oct 2009 06:57:38 -0700</pubDate>
         <content:encoded><![CDATA[<div class="content"><p>This week's Pick of the Week takes a turn "out of the box"; rather than select a file, I'd like to highlight new functionality in MATLAB that allows one to interface with the MATLAB Central File Exchange directly from one's <a rel="nofollow" target="_blank" href="http://www.mathworks.com/access/helpdesk/help/techdoc/matlab_env/f1-137804.html#f1-131542">MATLAB Desktop</a>. </p>  <p>As of the current release of MATLAB (R2009b), the Desktop includes a new tool called, appropriately, the <a rel="nofollow" target="_blank" href="http://www.mathworks.com/access/helpdesk/help/techdoc/rn/br5ktrh-1.html#br5ten7-1">File Exchange Desktop Tool</a>. To access the tool, simply browse from the MATLAB 'Start' button to 'Desktop Tools,' and then to 'File Exchange': </p> <p><img vspace="5" hspace="5" src="http://blogs.mathworks.com/pick/../images/pick/menuaccess.png"> </p> <p>From there, you'll be presented with a standard MATLAB window that will allow you to find and grab files from the Exchange.</p> <p><img vspace="5" hspace="5" src="http://blogs.mathworks.com/pick/../images/pick/fexdesktoptool.png"> </p> <p>Also, be sure to check out this <a rel="nofollow" target="_blank" href="http://www.mathworks.com/support/2009b/matlab/7.9/demos/new-matlab-file-exchange-access-features-in-r2009b.html">mini video tutorial</a> demonstrating these new capabilities. And be sure to <a rel="nofollow" target="_blank" href="http://blogs.mathworks.com/pick/?p=2471#respond">tell us what you think!</a></p><p style="text-align:right;font-size:xx-small;font-weight:lighter;font-style:italic;color:gray;"><br /><a rel="nofollow"><span style="font-size:x-small;font-style:italic;">Get the MATLAB code <noscript>(requires JavaScript)</noscript></span></a><br /><br /> Published with MATLAB&reg; 7.9<br /></p>
</div>
<img src="http://feeds.feedburner.com/~r/mathworks/pick/~4/ak2h-qApTf4" height="1" width="1"/>]]></content:encoded>
         <category>Picks</category>
      </item>
      <item>
         <title>Configurable keyboard shortcuts have arrived</title>
         <link>http://feedproxy.google.com/~r/mathworks/desktop/~3/cJZ0hhQ9XeQ/</link>
         <description>I&amp;#8217;d like to welcome guest blogger Christina Roberts from the MATLAB Editor team. Christina was the lead developer on the configurable keyboard shortcuts feature. R2009b has a new feature that I am particularly excited about: user-configurable keyboard shortcuts for the MATLAB desktop. This is a project that has been in the works for several years, and [...]</description>
         <guid isPermaLink="false">http://blogs.mathworks.com/desktop/2009/09/28/configurable-keyboard-shortcuts-have-arrived/</guid>
         <pubDate>Mon, 28 Sep 2009 06:41:38 -0700</pubDate>
         <content:encoded><![CDATA[<p><i><br />
I&#8217;d like to welcome guest blogger Christina Roberts from the MATLAB Editor team. Christina was the lead developer on the configurable keyboard shortcuts feature.<br />
</i></p>
<p>R2009b has a new feature that I am particularly excited about: <a rel="nofollow" target="_blank" href="http://www.mathworks.com/access/helpdesk/help/techdoc/index.html?/access/helpdesk/help/techdoc/matlab_env/br9elah.html#br5rvet">user-configurable keyboard shortcuts</a> for the MATLAB desktop. This is a project that has been in the works for several years, and I am thrilled that it is now officially released.</p>
<p>I will be splitting up my discussion of this feature into two posts. The first will give a high-level overview of the R2009b functionality, and the second will delve into the somewhat troubled history of keyboard shortcuts in MATLAB. I hope that you will learn some valuable tips from both posts and gain a better understanding of how to leverage customizable keyboard shortcuts.</p>
<p>First, let me explain the layout of the keyboard shortcut preference panel. You can open it from the File Menu: <strong>File -&gt; Preferences -&gt; Keyboard -&gt; Shortcuts</strong></p>
<div align="center">
<a rel="nofollow" target="_blank" href="http://blogs.mathworks.com/images/desktop/christina_roberts_keyboard_shortcuts/keyboard_shortcuts.png"><img border="0" src="http://blogs.mathworks.com/images/desktop/christina_roberts_keyboard_shortcuts/keyboard_shortcuts_small.png"></a><br />

</div>
<p>The <em>Active settings</em> dropdown list at the top of the preference panel allows you to choose between different keyboard shortcut sets—those that ship with the product, and customized sets that you may obtain from colleagues or <a rel="nofollow" target="_blank" href="http://www.mathworks.com/matlabcentral/fileexchange/?term=tag%3A%22keyboard+shortcuts%22">MATLAB Central</a>. The shortcut set selected by default matches common keyboard shortcuts on the platform on which you are running. For Windows and Macintosh, these are based on Windows and Macintosh platform standards, respectively. On UNIX, we decided to base our default keyboard shortcuts on the popular Emacs editor; however, if you are more comfortable with Windows-based keyboard shortcuts, that option is also available on UNIX.</p>
<p>The Windows and Emacs sets are both available on non-Macintosh platforms, but the Macintosh Default Set is only available on Macintosh due to the usage of the Command key. In addition to our new default sets, we also ship a set representing the <a rel="nofollow" target="_blank" href="http://www.mathworks.com/support/solutions/en/data/1-ANW4F9/?solution=1-ANW4F9">default keyboard shortcuts in R2009a</a>, specific to the platform on which you are running.</p>
<p>To import a customized keyboard shortcut set, choose <em>Browse…</em> from the <em>Active settings</em> combo box and navigate to the location of the set’s XML file. If you would like to share your own customized set, use the <em>Save As…</em> button to create an XML-representation of the set.</p>
<div align="center">
<img border="0" src="http://blogs.mathworks.com/images/desktop/christina_roberts_keyboard_shortcuts/browse_and_save_as.png">
</div>
<p>The top table of the preference panel lists all the actions that are configurable. You can search the contents of this table using the search field above it. For example, let’s look at the actions relating to pasting an item from the clipboard:</p>
<div align="center">
<a rel="nofollow" target="_blank" href="http://blogs.mathworks.com/images/desktop/christina_roberts_keyboard_shortcuts/paste.png"><img border="0" src="http://blogs.mathworks.com/images/desktop/christina_roberts_keyboard_shortcuts/paste_small.png"></a><br />

</div>
<p><br/>You can see that there are three paste-related actions. The generic <em>Paste</em> action has the keyboard shortcuts Ctrl+V and Shift+Insert. These same keyboard shortcuts are also assigned to <em>Paste to Workspace</em> in the Workspace Browser, as indicated by the informational icon next to the actions as well as their tooltips.</p>
<p>The middle table is where you can change assigned keyboard shortcuts, remove existing assignments, and add new ones. Let’s assume that you want to change <em>Paste</em>’s Ctrl+V shortcut to Ctrl+Shift+P. To do this, click in the table cell displaying Ctrl+V and press your new keyboard shortcut. The text representing the shortcut that you just pressed will then be displayed. Note that you can also insert multi-stroke keyboard shortcuts, popular in Emacs, by selecting <em>Limit to 2 keystrokes</em> from keyboard shortcut editor’s context menu.</p>
<div align="center">
<img border="0" src="http://blogs.mathworks.com/images/desktop/christina_roberts_keyboard_shortcuts/multi_stroke.png">
</div>
<p>If you press the <em>Apply</em> or <em>OK</em> buttons, Ctrl+V will be replaced by Ctrl+Shift+P for all tools which support the <em>Paste</em> action. To see what tools these are, click in the table cell to the right of the new assignment. It is then possible to deselect some of these tools, if you do not wish for Ctrl+Shift+P to be assigned to <em>Paste</em> in all desktop tools.</p>
<p>Now let’s also assign Ctrl+V back to <em>Paste</em> in the Editor only. To do this, press the <img border="0" src="http://blogs.mathworks.com/images/desktop/christina_roberts_keyboard_shortcuts/plus.png"> button under the middle table. Then press Ctrl+V in the shortcut field, and finally deselect all the tools for that shortcut except the MATLAB Editor.</p>
<div align="center">
<img border="0" src="http://blogs.mathworks.com/images/desktop/christina_roberts_keyboard_shortcuts/ctrl_v_editor.png">
</div>
<p>Finally, the bottom table in the panel shows keyboard shortcut conflicts with the action currently being edited. In the example above, informational icons indicate that there are keyboard shortcuts assigned to <em>Paste</em> which are also assigned to <em>Paste to Workspace</em>. However, since the Workspace Browser does not support the default <em>Paste</em> action, this is not an actual conflict. To create a real conflict, try replacing the Ctrl+Shift+P assignment with Ctrl+P.</p>
<div align="center">
<a rel="nofollow" target="_blank" href="http://blogs.mathworks.com/images/desktop/christina_roberts_keyboard_shortcuts/conflict.png"><img border="0" src="http://blogs.mathworks.com/images/desktop/christina_roberts_keyboard_shortcuts/conflict_small.png"></a><br />

</div>
<p><br/>When you make that change, an error icon appears, indicating that Ctrl+P is assigned to two or more actions within the same desktop tool. This means that you cannot use Ctrl+P for both <em>Paste</em> and <em>Print</em>, but you can instead choose to unassign Ctrl+P from <em>Print</em> by selecting the first row in the bottom table and pressing the <em>Unassign</em> button.</p>
<p>If you now press the <em>OK</em> or <em>Apply</em> button, your modifications to the Windows Default Set will be retained in subsequent sessions of MATLAB. You can go back to the original Windows Default Set by selecting <em>Restore defaults</em>, or you could write this file out as a custom set by selecting <em>Save As…</em>.</p>
<p>That is a quick overview of how the preference panel works. In a future post, I will discuss the history of keyboard shortcuts in MATLAB and explain how we made some of our design choices.</p>
<p><i>-by Christina Roberts, The MathWorks</i></p>
<img src="http://feeds.feedburner.com/~r/mathworks/desktop/~4/cJZ0hhQ9XeQ" height="1" width="1"/>]]></content:encoded>
      </item>
      <item>
         <title>Custom Components in Physical Models</title>
         <link>http://feedproxy.google.com/~r/SethOnSimulink/~3/KGJPeCF0cQE/</link>
         <description>This week I want to introduce
guest blogger Steve
Miller to talk about the Simscape language. Introduction to the Simscape
Language I’ve been working with MATLAB and
Simulink since my college days, and one of the things I liked most about these
tools is that I’m free to create just about anything with the commands and
blocks. Whenever my boss asked me, “Do [...]</description>
         <guid isPermaLink="false">http://blogs.mathworks.com/seth/2009/09/25/custom-components-in-physical-models/</guid>
         <pubDate>Fri, 25 Sep 2009 09:00:08 -0700</pubDate>
         <content:encoded><![CDATA[<p>This week I want to introduce
guest blogger <a rel="nofollow"
 target="_blank" href="http://www.mathworks.com/matlabcentral/fileexchange/authors/29641">Steve
Miller</a> to talk about the Simscape language.</p> <p><img src="http://blogs.mathworks.com/images/seth/2009Q3/SteveMiller.jpg" alt="Steve Miller - Physical Modeling Expert"></p> <p><strong>Introduction to the Simscape
Language</strong></p> <p>I’ve been working with MATLAB and
Simulink since my college days, and one of the things I liked most about these
tools is that I’m free to create just about anything with the commands and
blocks. Whenever my boss asked me, “Do you think you could use MATLAB to...,”
the enthusiastic “Yes!” was halfway out of my mouth before he even reached the
end of the sentence.</p> <p>When I started working with the <a rel="nofollow" target="_blank" href="http://physical-modeling.mathworks.com/">physical
modeling</a> products at The MathWorks,
I was hoping that I’d have the same freedom there. Well, starting with Release
2008b, I do! Using the <a rel="nofollow"
 target="_blank" href="http://www.mathworks.com/products/simscape/description4.html">Simscape language</a> (an
enhancement to Simscape, which was first released in R2007a), I can create my
own physical modeling blocks just like I created cool MATLAB scripts and
Simulink subsystems to solve all those tricky problems my boss threw at me.</p> <p><strong>What is the Simscape language?</strong></p> <p>The Simscape language is a
MATLAB-based, object-oriented language for modeling physical systems. The big
difference here is that I can use this textual language to create components
that have physical connections, such as hydraulic ports on valves and electrical
terminals on resistors, instead of inputs and outputs like I’m used to doing in
Simulink. Why is this important? Well the models built with physical
connections are much easier to understand – models of electrical systems look
like an electrical schematic. And, if I create something useful and I want to
reuse it in another model, it is much easier, for I don’t have to worry about
routing inputs and outputs -- I just plug my new electrical component into the
circuit and try it.</p> <p>Here is an example of a component
I have defined using the Simscape language. It’s a DC motor. You’ll see that
it has four physical ports (not inputs and outputs) – two electrical and two
mechanical. These physical ports let me plug the component into a physical
network.</p> <p><img src="http://blogs.mathworks.com/images/seth/2009Q3/Simscape_Language_Post_Image_1a.png" alt="Simscape - Custom DC Motor library"></p> <p><strong>How does it work?</strong></p> <p>You can use the Simscape language
to define physical domains, components, and libraries of components. It’s
usually easiest to look at an example, so let’s look at the definition of a DC
motor created in the Simscape language.</p> <p>Here we see the first 11 lines of
the file. This is where we define the component name, add a description, and
define the physical ports:</p> <p><img src="http://blogs.mathworks.com/images/seth/2009Q3/Simscape_Language_Post_Image_2a.png" alt="Simscape Component Definition of Nodes"></p> <p>You can see that we have two
electrical (+ and – terminals) and two mechanical rotational ports (motor shaft
and motor housing). These are reflected in the component shown above. </p> <p>In the next 6 lines of the file,
we define the parameters (including units!). These are the values that I or
another user may want to change:</p> <p><img src="http://blogs.mathworks.com/images/seth/2009Q3/Simscape_Language_Post_Image_3a.png" alt="Simscape parameters section"></p> <p>You’ll notice that in the final
component, the prompt, the default value, and the units all show up in the
dialog box shown here: </p> <p><img src="http://blogs.mathworks.com/images/seth/2009Q3/Simscape_Language_Post_Image_4a.png" alt="Simscape Custom DC Motor Parameters dialog box"></p> <p>Just like most Simscape blocks,
there a link to the source code! In lines 18-23 of the file, we define the
variables associated with the physical domains (electrical and mechanical) we need for the equations we will define in the
equations section.</p> <p><img src="http://blogs.mathworks.com/images/seth/2009Q3/Simscape_Language_Post_Image_5a.png" alt="Simscape variables section"></p> <p>In the setup section, we set up
the connections between the variables to the physical ports. Remember
Kirchoff’s laws? Well, we’re essentially applying them to both the electrical
and mechanical domains (yep, they work in other physical domains, too, if you
define them properly). </p> <p><img src="http://blogs.mathworks.com/images/seth/2009Q3/Simscape_Language_Post_Image_6a.png" alt="Simscape function setup section"></p> <p>You’ll also notice that we have used
MATLAB to make sure that the value of the resistance in the dialog box is not
less than zero. I can use MATLAB code in this section to do other things like
calculate values or initialize variables. All that MATLAB I learned is not
going to waste!</p> <p>In the last lines of the file, I
define the equations for the motor. Take a look:</p> <p><img src="http://blogs.mathworks.com/images/seth/2009Q3/Simscape_Language_Post_Image_7a.png" alt="Simscape equations section"></p> <p style=''>See
the “==” symbol there? I’ve used that to define an implicit equation. This
means I have set up a relationship between these quantities (including time
derivatives – see the <strong>.</strong><strong><span style='font-family:"Courier New";color:blue;'>der</span></strong>?). I’m not assigning values, nor does this represent a Boolean
expression. I could have defined them as shown below and the results would be
the same:</p> <p><img src="http://blogs.mathworks.com/images/seth/2009Q3/Simscape_Language_Post_Image_8a.png" alt="Simscape equations section - alternative"></p> <p>And there you have it! Once I
have defined the file, I execute <a rel="nofollow"
 target="_blank" href="http://www.mathworks.com/access/helpdesk/help/toolbox/physmod/simscape/ref/ssc_build.html">ssc_build</a>
and it produces a Simscape component I can connect to other Simscape components
in my physical model.</p> <p><strong>Videos of Simscape language in
action</strong></p> <p>I have made a video demo of <a rel="nofollow" target="_blank" href="http://www.mathworks.com/products/demos/simscape/Simscape_Language_Nonlinear_Spring/"> modeling a nonlinear spring using the Simscape language</a>. Take a look to see the blocks in use and the build
process.</p> <p>For a more complete experience,
watch this <a rel="nofollow" target="_blank" href="http://www.mathworks.com/wbnr31004">
webinar on the Simscape language</a>.</p> <p><strong>Now it’s your turn</strong></p> <p>Want a closer look at this
example? <a rel="nofollow"
 target="_blank" href="http://www.mathworks.com/matlabcentral/fileexchange/25014">
Download it</a> from the
MATLAB Central File Exchange.</p> <p>Are you using the physical
modeling tools? Have you tried the Simscape language? Post a <a rel="nofollow" target="_blank" href="http://blogs.mathworks.com/seth/?p=67&amp;#comment">
comment here</a> and tell us
about it.</p><img src="http://feeds.feedburner.com/~r/SethOnSimulink/~4/KGJPeCF0cQE" height="1" width="1"/>]]></content:encoded>
      </item>
      <item>
         <title>lasso.m</title>
         <link>http://feedproxy.google.com/~r/mathworks/pick/~3/86TtHHO2BfE/</link>
         <description>Bob's pick this week is lasso.m by Thomas Rutten. Suppose you have a set of XY points. You plot them to see how they spread out. You decide a certain clump of points is special. [...]</description>
         <guid isPermaLink="false">http://blogs.mathworks.com/pick/2009/09/25/lassom/</guid>
         <pubDate>Fri, 25 Sep 2009 04:51:36 -0700</pubDate>
         <content:encoded><![CDATA[<div class="content"><p><a rel="nofollow" target="_blank" href="http://www.mathworks.com/matlabcentral/fileexchange/authors/5021">Bob</a>'s pick this week is <a rel="nofollow" target="_blank" href="http://www.mathworks.com/matlabcentral/fileexchange/3991">lasso.m</a> by Thomas Rutten. </p>  <p>Suppose you have a set of XY points. You plot them to see how they spread out. You decide a certain clump of points is special. How do you get MATLAB to know which points you care about? With <tt>lasso</tt> you can select them with your mouse! </p> <p>To demonstrate I will use the sunspot example data that ships with MATLAB.</p><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);">load <span style="color:#A020F0;">sunspot.dat</span>
[x,y,i] = lasso(sunspot(:,1),sunspot(:,2))</pre><pre style="font-style:oblique;">press a KEY to start selection by mouse, LEFT mouse button for selection, RIGHT button closes loop
x = 1836 1837 1848 1870
y = 121.5 138.3 124.7 139
i = 137 138 149 171
</pre><img vspace="5" hspace="5" src="http://blogs.mathworks.com/images/pick/pick_lasso_01.png"> <img vspace="5" hspace="5" src="http://blogs.mathworks.com/images/pick/pick_lasso_02.png"> <pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);">centroid = [mean(x) mean(y)]</pre><pre style="font-style:oblique;">centroid = 1847.8 130.88
</pre><p>The program prompted me how to start and stop the selection. I left off the semicolon to show the values returned for further analysis (ie, centroid calculation). The first plot shows the polygon region I selected. The second plot shows the selected points with a free legend and point counter. Nice! </p> <p>Note: if you like graphically interacting with your XY points be sure to check out <a rel="nofollow" target="_blank" href="http://www.mathworks.com/access/helpdesk/help/techdoc/rn/brfrh4i-1.html#brfrh4i-2">Data Brushing</a> introduced with R2008a. </p> <p><a rel="nofollow" target="_blank" href="http://blogs.mathworks.com/pick/?p=2467#respond">Comments?</a></p><p style="text-align:right;font-size:xx-small;font-weight:lighter;font-style:italic;color:gray;"><br /><a rel="nofollow"><span style="font-size:x-small;font-style:italic;">Get the MATLAB code <noscript>(requires JavaScript)</noscript></span></a><br /><br /> Published with MATLAB&reg; 7.9<br /></p>
</div>
<img src="http://feeds.feedburner.com/~r/mathworks/pick/~4/86TtHHO2BfE" height="1" width="1"/>]]></content:encoded>
         <category>Picks</category>
      </item>
      <item>
         <title>The Front Page of the File Exchange: Your Desktop</title>
         <link>http://feedproxy.google.com/~r/mathworks/desktop/~3/vIAaWYgxLLQ/</link>
         <description>It may seem backward in late 2009 that one of the great new features in MATLAB is integrating a web application, the MATLAB File Exchange, into the Desktop. However it&amp;#8217;s not surprising to me that this arrangement works out quite well. Because the file exchange exists for sharing files created in and to be used [...]</description>
         <guid isPermaLink="false">http://blogs.mathworks.com/desktop/2009/09/21/the-front-page-of-the-file-exchange-your-desktop/</guid>
         <pubDate>Mon, 21 Sep 2009 05:37:39 -0700</pubDate>
         <content:encoded><![CDATA[<p>It may seem backward in late 2009 that one of the great new features in MATLAB is integrating a web application, the MATLAB File Exchange, into the Desktop. However it&#8217;s not surprising to me that this arrangement works out quite well. Because the file exchange exists for sharing files created in and to be used in the MATLAB environment, this actually streamlines the workflow. This new tool solves the pain of making files from the exchange available and searchable right there without having to leave MATLAB. </p>
<p>The File Exchange window is not open by default, so to bring it up, use the toolbar menu: <strong> Desktop -&gt; File Exchange</strong>.</p>
<p>Downloading is quite simple. Let&#8217;s say I wanted to download Ken&#8217;s <a rel="nofollow" target="_blank" href="http://blogs.mathworks.com/desktop/2009/07/13/muting-breakpoints/">breakpoint muting</a> program:<br />
1. Search<br />
2. Download</p>
<div align="center"><a rel="nofollow" target="_blank" href="http://blogs.mathworks.com/images/desktop/michael_katz_fxim/fex_search.png"><img src="http://blogs.mathworks.com/images/desktop/michael_katz_fxim/fex_search_small.png" alt="File Exchange search" border="0"/></a></div>
<p>3. Go</p>
<div align="center"><img src="http://blogs.mathworks.com/images/desktop/michael_katz_fxim/fex_go.png" alt="File Exchange search" border="0"/></div>
<p>It&#8217;s pretty a simple feature, but the convenience factor is really there. You can search for toolbox functions using the <a rel="nofollow" target="_blank" href="http://blogs.mathworks.com/desktop/2008/10/27/the-function-browser/">Function Browser</a>, and if we didn&#8217;t give you a particular function, you can then turn to the File Exchange and see if one of your friends on the web has already done the work for you. </p>
<p>The file exchange is an active and friendly community and if you&#8217;ve come up with useful program, we encourage you to share that with the community through the File Exchange <a rel="nofollow" target="_blank" href="http://www.mathworks.com/matlabcentral/fileexchange/">web interface</a>. If your program is up to snuff, it may even be chosen as the <a rel="nofollow" target="_blank" href="http://blogs.mathworks.com/pick/">File Exchange Pick of the Week</a>.</p>
<p>Resources:</p>
<ol>
<li><a rel="nofollow" target="_blank" href="http://www.mathworks.com/access/helpdesk/help/techdoc/index.html?/access/helpdesk/help/techdoc/matlab_env/br58q3h-1.html&#038;http://www.mathworks.com/access/helpdesk/help/techdoc/helptoc.html">FAQ</a></li>
<li>Watch the <a rel="nofollow" target="_blank" href="http://www.mathworks.com/support/2009b/matlab/7.9/demos/new-matlab-file-exchange-access-features-in-r2009b.html">tutorial video</a></li>
</ol>
<img src="http://feeds.feedburner.com/~r/mathworks/desktop/~4/vIAaWYgxLLQ" height="1" width="1"/>]]></content:encoded>
      </item>
      <item>
         <title>How do I test for NaN in Simulink R2009b? (NEW!)</title>
         <link>http://feedproxy.google.com/~r/SethOnSimulink/~3/EnmGi2a6SZM/</link>
         <description>Back in February 2009 I posted about how
to test for NaN in Simulink. The approach I talked about was more of a
logical experiment based on the special properties of NaN than an ideal
software solution. In Simulink R2009b the Relational
Operator block got an upgrade to include isNaN. Let’s see how it works. Relational Operator Block Upgrade The Relational [...]</description>
         <guid isPermaLink="false">http://blogs.mathworks.com/seth/2009/09/18/how-do-i-test-for-nan-in-simulink-r2009b-new/</guid>
         <pubDate>Fri, 18 Sep 2009 09:00:15 -0700</pubDate>
         <content:encoded><![CDATA[<style>
<!-- _filtered {font-family:Wingdings;panose-1:5 0 0 0 0 0 0 0 0 0;}
 _filtered {font-family:"Cambria Math";panose-1:2 4 5 3 5 4 6 3 2 4;}
 _filtered {font-family:Calibri;panose-1:2 15 5 2 2 2 4 3 2 4;}
 _filtered {font-family:Tahoma;panose-1:2 11 6 4 3 5 4 4 2 4;}/* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {margin-top:0in;margin-right:0in;margin-bottom:10.0pt;margin-left:0in;line-height:115%;font-size:11.0pt;font-family:"Calibri", "sans-serif";}
a:link, span.MsoHyperlink {color:blue;text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed {color:purple;text-decoration:underline;}
pre {margin:0in;margin-bottom:.0001pt;font-size:10.0pt;font-family:"Courier New";color:#1122AA;}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate {margin:0in;margin-bottom:.0001pt;font-size:8.0pt;font-family:"Tahoma", "sans-serif";}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph {margin-top:0in;margin-right:0in;margin-bottom:10.0pt;margin-left:.5in;line-height:115%;font-size:11.0pt;font-family:"Calibri", "sans-serif";}
p.MsoListParagraphCxSpFirst, li.MsoListParagraphCxSpFirst, div.MsoListParagraphCxSpFirst {margin-top:0in;margin-right:0in;margin-bottom:0in;margin-left:.5in;margin-bottom:.0001pt;line-height:115%;font-size:11.0pt;font-family:"Calibri", "sans-serif";}
p.MsoListParagraphCxSpMiddle, li.MsoListParagraphCxSpMiddle, div.MsoListParagraphCxSpMiddle {margin-top:0in;margin-right:0in;margin-bottom:0in;margin-left:.5in;margin-bottom:.0001pt;line-height:115%;font-size:11.0pt;font-family:"Calibri", "sans-serif";}
p.MsoListParagraphCxSpLast, li.MsoListParagraphCxSpLast, div.MsoListParagraphCxSpLast {margin-top:0in;margin-right:0in;margin-bottom:10.0pt;margin-left:.5in;line-height:115%;font-size:11.0pt;font-family:"Calibri", "sans-serif";}
span.BalloonTextChar {font-family:"Tahoma", "sans-serif";}
span.HTMLPreformattedChar {font-family:"Courier New";color:#1122AA;}
span.ln1 {color:#888888;font-style:italic;}
span.ct1 {color:#117755;font-style:italic;}
span.dt1 {color:#112266;}
span.pp1 {color:#992211;}
span.kw1 {color:#112266;}
.MsoPapDefault {margin-bottom:10.0pt;line-height:115%;}
 _filtered {margin:1.0in 1.0in 1.0in 1.0in;}
div.Section1 {}/* List Definitions */ ol {margin-bottom:0in;}
ul {margin-bottom:0in;}
-->
</style><p>Back in February 2009 I posted about <a rel="nofollow"
 target="_blank" href="http://blogs.mathworks.com/seth/2009/02/04/how-do-i-test-for-nan-in-my-model/">how
to test for NaN in Simulink</a>. The approach I talked about was more of a
logical experiment based on the special properties of NaN than an ideal
software solution. In Simulink R2009b the <a rel="nofollow"
 target="_blank" href="http://www.mathworks.com/access/helpdesk/help/toolbox/simulink/slref/relationaloperator.html">Relational
Operator block</a> got an upgrade to include isNaN. Let’s see how it works.</p> <p><strong>Relational Operator Block Upgrade</strong></p> <p>The Relational Operator is often used to compare signals and
test for greater than (&gt;), equals (==), and more. In R2009b it has the
following new single input modes: isNaN, isFinite, and isInf<strong>.</strong></p> <p><img src="http://blogs.mathworks.com/images/seth/2009Q3/isNaNBlock.png" alt="The Relational Operator in Simulink R2009b has the isNaN operation."></p> <p><img src="http://blogs.mathworks.com/images/seth/2009Q3/relOpParameters.png" alt="The parameters for the relational operator block in Simulink R2009b"></p> <p>These functions are familiar to those who program in MATLAB
and they work the same way. When the input signal has the properties we are
testing for, the block outputs true.</p> <p><strong>How does it work?</strong></p> <p>I talked to my colleague Omar who upgraded the block and he
shared with me some key points. He mentioned that the block handles:</p> <p><ul> <li>real and complex signals</li> <li>any data type supported by Simulink including fixed point types</li> <li>endianness of your platform</li> </ul>
</p> <p>These new operators are only meaningful with data types that
can represent Inf and NaN. <em>So how does it work with non-floating point
types?</em> If you pass in an integer, or a fixed-point type that cannot
represent NaN of Inf, the block returns false. This is a key point for
workflows where you might find yourself switching the data types in your design. This often happens when selecting proper fixed-point data type properties. If
you are running simulations to gather ideal double precision results, you may
need to handle Inf and NaN. When converting the model to fixed-point for implementation,
the algorithm does not require any modifications.</p> <p><strong>Generated Code</strong></p> <p>The code generated for the isNaN function looks like this:</p> <p style='margin-bottom:0in;margin-bottom:.0001pt;
line-height:normal;'><em><span style='font-size:10.0pt;font-family:"Courier New";color:#888888;'> 34 </span></em><span style='font-size:10.0pt;font-family:"Courier New";color:#1122AA;'> </span><em><span style='font-size:10.0pt;font-family:"Courier New";color:#117755;'>/* Outport: ‘</span></em><em><span style='font-size:10.0pt;font-family:"Courier New";color:#117755;'>&lt;Root&gt;/Out1</span></em><em><span
 style='font-size:10.0pt;font-family:"Courier New";color:#117755;'>’
incorporates:</span></em><br /> <em><span style='font-size:10.0pt;font-family:"Courier New";color:#888888;'> 35 </span></em><em><span style='font-size:10.0pt;font-family:"Courier New";color:#117755;'> * Inport: ‘</span></em><em><span style='font-size:10.0pt;font-family:"Courier New";color:#117755;'>&lt;Root&gt;/In1</span></em><em><span
 style='font-size:10.0pt;font-family:"Courier New";color:#117755;'>’</span></em><br /> <em><span style='font-size:10.0pt;font-family:"Courier New";color:#888888;'> 36 </span></em><em><span style='font-size:10.0pt;font-family:"Courier New";color:#117755;'> * RelationalOperator: ‘</span></em><em><span style='font-size:10.0pt;font-family:"Courier New";color:#117755;'>&lt;Root&gt;/Relational Operator</span></em><em><span
 style='font-size:10.0pt;font-family:"Courier New";color:#117755;'>’</span></em><br /> <em><span style='font-size:10.0pt;font-family:"Courier New";color:#888888;'> 37 </span></em><em><span style='font-size:10.0pt;font-family:"Courier New";color:#117755;'> */</span></em><br /> <em><span style='font-size:10.0pt;font-family:"Courier New";color:#888888;'> 38 </span></em><span style='font-size:10.0pt;font-family:"Courier New";color:#1122AA;'> isNaNCode_Y.Out1 = </span><span style='font-size:10.0pt;
font-family:"Courier New";'>rtIsNaN</span><span style='font-size:10.0pt;
font-family:"Courier New";color:#1122AA;'>(isNaNCode_U.In1);</span><br /> <p>The function rtIsNaN is part of rt_nonfinite.c:</p> <pre style='margin-bottom:0in;margin-bottom:.0001pt;
line-height:normal;'><span class="ln1"> 61 </span><span class="ct1">/* Test if value is not a number */</span></pre><pre style='margin-bottom:0in;margin-bottom:.0001pt;
line-height:normal;'><span
 class="ln1"> 62 </span><span style='color:#1122AA;'>boolean_T</span> rtIsNaN(<span style='color:#1122AA;'>real_T</span> value)</pre><pre style='margin-bottom:0in;margin-bottom:.0001pt;
line-height:normal;'><span
 class="ln1"> 63 </span><strong>{</strong></pre><pre style='margin-bottom:0in;margin-bottom:.0001pt;
line-height:normal;'><span class="ln1"> 64 </span></pre><pre style='margin-bottom:0in;margin-bottom:.0001pt;
line-height:normal;'><span
 class="ln1"> 65 </span><span style='color:#992211;'>#<span class="pp1">if</span></span> <span
 class="pp1">defined</span>(_MSC_VER) &amp;&amp; (_MSC_VER &lt;= 1200)</pre><pre style='margin-bottom:0in;margin-bottom:.0001pt;
line-height:normal;'><span
 class="ln1"> 66 </span></pre><pre style='margin-bottom:0in;margin-bottom:.0001pt;
line-height:normal;'><span class="ln1"> 67 </span> <span
 class="ct1">/* For MSVC 6.0, use a compiler specific comparison function */</span></pre><pre style='margin-bottom:0in;margin-bottom:.0001pt;
line-height:normal;'><span
 class="ln1"> 68 </span> <span class="kw1">return</span> _isnan(value)? 1U:0U;</pre><pre style='margin-bottom:0in;margin-bottom:.0001pt;
line-height:normal;'><span
 class="ln1"> 69 </span></pre><pre><span class="ln1"> 70 </span><span
 style='color:#992211;'>#<span class="pp1">else</span></span></pre><pre style='margin-bottom:0in;margin-bottom:.0001pt;
line-height:normal;'><span
 class="ln1"> 71 </span></pre><pre><span class="ln1"> 72 </span> <span
 class="kw1">return</span>((value!=value) ? 1U : 0U);</pre><pre style='margin-bottom:0in;margin-bottom:.0001pt;
line-height:normal;'><span class="ln1"> 73 </span></pre><pre style='margin-bottom:0in;margin-bottom:.0001pt;
line-height:normal;'><span
 class="ln1"> 74 </span><span style='color:#992211;'>#<span class="pp1">endif</span></span></pre><pre style='margin-bottom:0in;margin-bottom:.0001pt;
line-height:normal;'><span
 class="ln1"> 75 </span></pre><pre style='margin-bottom:0in;margin-bottom:.0001pt;
line-height:normal;'><span class="ln1"> 76 </span><strong>}</strong></pre> <p><strong>Further Optimization using Target Function Library</strong></p> <p>If your embedded target environment has a special function
for handling tests for NaN, Inf or Finiteness you can use the <a rel="nofollow"
 target="_blank" href="http://www.mathworks.com/access/helpdesk/help/toolbox/ecoder/ug/brc_o1j.html">Target
Function Library</a> to replace the call to rtIsNaN with that call.</p> <p><strong>What do you think?</strong></p> <p>Will you use the isInf, isNaN and isFinite mode of this
block? Leave a <a rel="nofollow" target="_blank" href="http://blogs.mathworks.com/seth/?p=66&amp;#comment">comment
here</a> to tell me how.</p><img src="http://feeds.feedburner.com/~r/SethOnSimulink/~4/EnmGi2a6SZM" height="1" width="1"/>]]></content:encoded>
      </item>
      <item>
         <title>Easier (and less error-prone) creation of Zip files</title>
         <link>http://feedproxy.google.com/~r/mathworks/pick/~3/dFIPpiGs8zw/</link>
         <description>Brett's Pick this week is exportToZip, by fellow MathWorker Malcolm Wood. I recently received an email from a File Exchange user informing me that a GUI I had shared for morphologically processing [...]</description>
         <guid isPermaLink="false">http://blogs.mathworks.com/pick/2009/09/18/easier-and-less-error-prone-creation-of-zip-files/</guid>
         <pubDate>Fri, 18 Sep 2009 07:21:19 -0700</pubDate>
         <content:encoded><![CDATA[<div class="content"><p><a rel="nofollow" target="_blank" href="http://www.mathworks.com/matlabcentral/fileexchange/authors/911">Brett</a>'s Pick this week is <a rel="nofollow" target="_blank" href="http://www.mathworks.com/matlabcentral/fileexchange/10702"><tt>exportToZip</tt></a>, by fellow MathWorker <a rel="nofollow" target="_blank" href="http://www.mathworks.com/matlabcentral/fileexchange/authors/21286">Malcolm Wood</a>. </p>  <p>I recently received an email from a File Exchange user informing me that a GUI I had shared for morphologically processing images (i.e., <a rel="nofollow" target="_blank" href="http://www.mathworks.com/matlabcentral/fileexchange/23697"><tt>morphTool</tt></a>) didn't work. As it turns out, I had neglected to include in the Zip file that I uploaded a couple of functions that were called internally by <tt>morphTool</tt>. </p> <p>I've made the same mistake before, and I've also downloaded File Exchange files that were missing some key functionality.</p> <p>This email exchange had me thinking about writing a bit of code to automatically create my Zip files, making sure to include all necessary supporting function files. MATLAB has a <a rel="nofollow" target="_blank" href="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/depfun.html"><tt>depfun</tt></a> command that will <i>thoroughly</i> analyze a function and determine its dependencies, including, by default, functions in MATLAB Toolboxes. It can take a little while to generate a report, though, and does a lot more work than is necessary just to create a comprehensive Zip file. Alternatively, one can easily <a rel="nofollow" target="_blank" href="http://www.mathworks.com/access/helpdesk/help/techdoc/rn/f3-998197.html#f3-1007592">create a dependency report</a> for the current file active in the MATLAB editor by using "Save and Show Dependency Report" from the Tools menu. That approach is much faster than using <tt>depfun</tt> (with its default options), but leaves you then to manually evaluate one-by-one each function that your top-level function calls. As you might guess, it's easy to miss a necessary file when you create your Zip. </p> <p>Before I started coding, I thought I'd check the File Exchange (wouldn't you?), and I quickly found Malcolm's <tt>exportToZip</tt>. Malcolm's file uses his own version of <tt>depfun</tt> (called <tt>mydepfun</tt>), that smartly uses non-default behavior of <tt>depfun</tt> to automatically skip files in MATLAB Toolboxes; <tt>mydepfun</tt> returns the paths to just those files needed for the target Zip file, which is then automatically created. </p> <p>I tried <tt>exportToZip</tt> on <tt>morphTool</tt>; it worked flawlessly--and quickly! And syntactically, it couldn't be easier to use: </p> <p><tt>zipfilename = exportToZip(funcname,zipfilename)</tt></p> <p>Oh, and incidentally, a new version of <tt>morphTool</tt> will go live soon. Thanks, Malcolm--you saved me a lot of time and effort! </p> <p>You gotta love the File Exchange!</p> <p><a rel="nofollow" target="_blank" href="http://blogs.mathworks.com/pick/?p=2465#respond">Comments?</a></p><p style="text-align:right;font-size:xx-small;font-weight:lighter;font-style:italic;color:gray;"><br /><a rel="nofollow"><span style="font-size:x-small;font-style:italic;">Get the MATLAB code <noscript>(requires JavaScript)</noscript></span></a><br /><br /> Published with MATLAB&reg; 7.8<br /></p>
</div>
<img src="http://feeds.feedburner.com/~r/mathworks/pick/~4/dFIPpiGs8zw" height="1" width="1"/>]]></content:encoded>
         <category>Picks</category>
      </item>
      <item>
         <title>MATLAB Release 2009b - Best New Feature or ~?</title>
         <link>http://feedproxy.google.com/~r/mathworks/loren/~3/YydACyi7Iqc/</link>
         <description>MATLAB R2009b was recently released. My favorite new language feature is the introduction of the ~ notation to denote missing inputs in function declarations, and missing outputs in calls to functions. Let me show you how this works. [...]</description>
         <guid isPermaLink="false">http://blogs.mathworks.com/loren/2009/09/11/matlab-release-2009b-best-new-feature-or/</guid>
         <pubDate>Fri, 11 Sep 2009 07:13:25 -0700</pubDate>
         <content:encoded><![CDATA[<div class="content"><p><a rel="nofollow" target="_blank" href="http://www.mathworks.com/products/new_products/latest_features.html">MATLAB R2009b</a> was recently released. My favorite new language feature is the introduction of the <a rel="nofollow" target="_blank" href="http://www.mathworks.com/access/helpdesk/help/techdoc/matlab_prog/bresuxt-1.html#br67dkp-1"><tt>~</tt> notation</a> to denote missing inputs in function declarations, and missing outputs in calls to functions. Let me show you how this works. </p>  <h3>Contents</h3> <div> <ul> <li><a rel="nofollow" href="#1">Unused Outputs</a></li> <li><a rel="nofollow" href="#4">Unused Inputs</a></li> <li><a rel="nofollow" href="#6">Can M-Lint Help?</a></li> <li><a rel="nofollow" href="#11">What's Your Favorite New Feature?</a></li> </ul> </div> <h3>Unused Outputs<a rel="nofollow" name="1"></a></h3> <p>I have occasionally found that I would like the indices from sorting a vector, but I don't need the sorted values. In the past, I wrote one of these code variants : </p><pre> [dummy, ind] = sort(X) [ind, ind] = sort(X)</pre><p>In the first case, I end up with a variable <tt>dummy</tt> in my workspace that I don't need. If my data to sort, <tt>X</tt>, has a large number of elements, I will have an unneeded large array hanging around afterwards. In the second case, I am banking on MATLAB assigning outputs in order, left to right, and I create somewhat less legible code, but I don't have an extra array hanging around afterwards. </p> <p>Now you can write this instead:</p><pre> [~, ind] = sort(X)</pre><p>and I hope you find your code readable, with the clear intention to not use the first output variable.</p> <h3>Unused Inputs<a rel="nofollow" name="4"></a></h3> <p>You can similarly designate unused inputs with <tt>~</tt> in function declarations. Here's how you'd define the interface where the second input is ignored. </p><pre> function out = mySpecialFunction(X,~,dim)</pre><p>You might ask why that is useful. If I don't use the second input, why put it in at all? The answer is that your function might be called by some other function that expects to send three inputs. This happens for many GUI callbacks, and particularly those you generate using <a rel="nofollow" target="_blank" href="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/guide.html"><tt>guide</tt></a>. So your function needs to take three inputs. But if it is never going to use the second input, you can denote the second one with <tt>~</tt>. </p> <h3>Can M-Lint Help?<a rel="nofollow" name="6"></a></h3> <p>Yes! Consider this function <tt>mySpecialFunction</tt> shown here. </p><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);">type <span style="color:#A020F0;">mySpecialFunction</span></pre><pre style="font-style:oblique;">
function ind = mySpecialFunction(X,second,dim)
% mySpecialFunction Function to illustrate ~ for inputs and outputs. [dummy,ind] = sort(X,dim);
</pre><p>Running <a rel="nofollow" target="_blank" href="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/mlint.html"><tt>mlint</tt></a> on this code produces two messages. </p><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);">msgs = mlint(<span style="color:#A020F0;">'mySpecialFunction'</span>);
disp(msgs(1).message(1:50))
disp(msgs(1).message(51:end))
disp(<span style="color:#A020F0;">' '</span>)
disp(msgs(2).message(1:49))
disp(msgs(2).message(50:end))</pre><pre style="font-style:oblique;">Input argument 'second' might be unused, although a later one is used. Consider replacing it by ~. The value assigned here to 'dummy' appears to be unused. Consider replacing it by ~.
</pre><p>Since M-Lint is running continuously in the editor, you would see these messages as you edit the file. Here's a cleaned up version of the file. </p><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);">type <span style="color:#A020F0;">mySpecialFunction1</span></pre><pre style="font-style:oblique;">
function ind = mySpecialFunction1(X,~,dim)
% mySpecialFunction Function to illustrate ~ for inputs and outputs. [~,ind] = sort(X,dim);
</pre><p>And let's see what M-Lint finds.</p><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);">mlint <span style="color:#A020F0;">mySpecialFunction1</span></pre><p>It finds nothing at all.</p> <h3>What's Your Favorite New Feature?<a rel="nofollow" name="11"></a></h3> <p>Have you looked through the <a rel="nofollow" target="_blank" href="http://www.mathworks.com/products/matlab/whatsnew.html">new features</a> for R2009b? What's your favorite? Let me know <a rel="nofollow" target="_blank" href="http://blogs.mathworks.com/loren/?p=198#respond">here</a>. </p><p style="text-align:right;font-size:xx-small;font-weight:lighter;font-style:italic;color:gray;"><br /><a rel="nofollow"><span style="font-size:x-small;font-style:italic;">Get the MATLAB code <noscript>(requires JavaScript)</noscript></span></a><br /><br /> Published with MATLAB&reg; 7.9<br /></p>
</div>
<img src="http://feeds.feedburner.com/~r/mathworks/loren/~4/YydACyi7Iqc" height="1" width="1"/>]]></content:encoded>
      </item>
      <item>
         <title>New Stuff – Simulink R2009b</title>
         <link>http://feedproxy.google.com/~r/SethOnSimulink/~3/8hTuxzZ91hI/</link>
         <description>Last week the MathWorks released the R2009b family of
products. There are many new capabilities in the latest release and with this
blog post, I want to highlight a some of the features in Simulink I’m really
excited about. While you read this, start installing the latest products from
the MathWorks.com
downloads area (login and license required). Reading the release notes [...]</description>
         <guid isPermaLink="false">http://blogs.mathworks.com/seth/2009/09/09/new-stuff-%e2%80%93-simulink-r2009b/</guid>
         <pubDate>Tue, 08 Sep 2009 18:56:01 -0700</pubDate>
         <content:encoded><![CDATA[<p>Last week the MathWorks released the R2009b family of
products. There are many new capabilities in the latest release and with this
blog post, I want to highlight a some of the features in Simulink I’m really
excited about. While you read this, start installing the latest products from
the <a rel="nofollow" target="_blank" href="http://www.mathworks.com/downloads/web_downloads">MathWorks.com
downloads area</a> (login and license required).</p> <p><strong>Reading the release notes is so R2007b!</strong></p> <p>Did you know that there is a presentation containing <a rel="nofollow"
 target="_blank" href="http://www.mathworks.com/products/new_products/Simulink_R2009b.pdf">highlights
and screen shots from R2009b Simulink</a>? If you have missed this in the
past, you can go back and check out <a rel="nofollow"
 target="_blank" href="http://www.mathworks.com/products/new_products/Simulink_R2008a_v3.pdf">R2008a</a>,
<a rel="nofollow" target="_blank" href="http://www.mathworks.com/products/new_products/Simulink_R2008b.pdf">R2008b</a>
and <a rel="nofollow" target="_blank" href="http://www.mathworks.com/products/new_products/Simulink_R2009a.pdf">R2009a</a>
highlights. Try it yourself, and browse through all the <a rel="nofollow"
 target="_blank" href="http://www.mathworks.com/products/new_products/Simulink_R2009b.pdf">cool
new features in R2009b Simulink</a>.</p> <p><img src="http://blogs.mathworks.com/images/seth/2009Q3/FeatureSlides9b.png" alt="R2009b Simulink Feature Slides"></p> <p><strong>Model Reference Protected Models!</strong></p> <p>Share your model functionality without sharing your model
intellectual property! Anyone with R2009b Simulink can use a protected model. If you have a license to Real-Time Workshop, you can create a protected model.</p> <p><img src="http://blogs.mathworks.com/images/seth/2009Q3/mdlrefProtected.png" alt="Model Reference Protected Mode"></p> <p><strong>Model Reference Variants</strong></p> <p>If you have multiple implementations of your component model,
variant objects enable you to control the implementation used. This allows you
to globally control and coordinate switching between variant implementations of
your model.</p> <p><img src="http://blogs.mathworks.com/images/seth/2009Q3/mdlrefVariants.png" alt="Simulink Model Reference Variants"></p> <p><strong>Tabs in the Mask Editor!</strong></p> <p>Now you can create tabs in your custom block masks.</p> <p><img src="http://blogs.mathworks.com/images/seth/2009Q3/maskTabs.png" alt="Simulink R2009b masks include tabs!"></p> <p><strong>Variably Sized Signals!</strong></p> <p>Special blocks and Embedded MATLAB now support dynamically
sizing signals during simulation!</p> <p><img src="http://blogs.mathworks.com/images/seth/2009Q3/varSize.png" alt="Variable sized signals in Simulink R2009b"></p> <p><strong>The SIM command can return a single output!</strong></p> <p>The SIM command has a new single output syntax so all your results
are part of a single SimulationOutput object. This enables SIM to be called
within a PARFOR loop, thus enabling easy parallel Simulation using the Parallel
Computing Toolbox.</p> <code style="font-size:11pt;">paramNameValStruct.SimulationMode = 'rapid';<br /> paramNameValStruct.AbsTol = '1e-5';<br /> paramNameValStruct.SaveState = 'on';<br /> paramNameValStruct.StateSaveName = 'xoutNew';<br /> paramNameValStruct.SaveOutput = 'on';<br /> paramNameValStruct.OutputSaveName = 'youtNew';<br /> simOut = sim('vdp',paramNameValStruct);</code> <p><strong>New Library Links Tool for fixing broken links!</strong></p> <p>After making changes to a model and disabling library links,
the Library Links tool will enable you to reestablish those links to your
library. Each change in the model can be pushed back into the library, or the
block can be restored from the original library source. </p> <p><img src="http://blogs.mathworks.com/images/seth/2009Q3/linksTool.png" alt="The R2009b Simulink Library Links Tool"></p> <p><strong>Now it’s your turn</strong></p> <p>Have you downloaded R2009b? Leave a <a rel="nofollow"
 target="_blank" href="http://blogs.mathworks.com/seth/?p=65&amp;#comment">comment here</a> and
tell me about your favorite new features.</p>
<img src="http://feeds.feedburner.com/~r/SethOnSimulink/~4/8hTuxzZ91hI" height="1" width="1"/>]]></content:encoded>
      </item>
      <item>
         <title>Rounding Results</title>
         <link>http://feedproxy.google.com/~r/mathworks/loren/~3/Mq6sv7LgnHE/</link>
         <description>There are frequent questions on the MATLAB newsgroup about rounding results to a certain number of decimal places. MATLAB itself doesn't provide this functionality explicitly, though it is easy to accomplish. [...]</description>
         <guid isPermaLink="false">http://blogs.mathworks.com/loren/2009/09/03/rounding-results/</guid>
         <pubDate>Thu, 03 Sep 2009 07:38:27 -0700</pubDate>
         <content:encoded><![CDATA[<div class="content"><p>There are frequent questions on the <a rel="nofollow" target="_blank" href="http://www.mathworks.com/matlabcentral/newsreader/">MATLAB newsgroup</a> about rounding results to a certain number of decimal places. MATLAB itself doesn't provide this functionality explicitly, though it is easy to accomplish. </p>  <h3>Contents</h3> <div> <ul> <li><a rel="nofollow" href="#1">Sidetrack : A Little MathWorks History</a></li> <li><a rel="nofollow" href="#2">Example</a></li> <li><a rel="nofollow" href="#7">Tools for Rounding Solutions</a></li> <li><a rel="nofollow" href="#9">Question for You</a></li> </ul> </div> <h3>Sidetrack : A Little MathWorks History<a rel="nofollow" name="1"></a></h3> <p>MathWorks' first Massachusetts office phone number was 653-1415 (ignoring country and area codes). The astute reader will notice that the last 5 digits are an approximation for <img vspace="5" hspace="5" src="http://blogs.mathworks.com/images/loren/197/rounding_eq11731.png"> (or, in MATLAB, <a rel="nofollow" target="_blank" href="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/pi.html"><tt>pi</tt></a>). A local resident called one day to say that she kept getting calls for MathWorks and she wasn't sure why. But it was quite inconvenient for her because she spent lots of time on the second floor of her home, and the phone was on the first floor. The excess round-trips were taxing her! To understand what was happening, you should know that in some of the early MathWorks materials, the phone number was listed as <img vspace="5" hspace="5" src="http://blogs.mathworks.com/images/loren/197/rounding_eq41424.png"> <img vspace="5" hspace="5" src="http://blogs.mathworks.com/images/loren/197/rounding_eq11731.png"> . </p> <h3>Example<a rel="nofollow" name="2"></a></h3><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);">format <span style="color:#A020F0;">long</span>
x = 1.23456789</pre><pre style="font-style:oblique;">x = 1.234567890000000
</pre><p>Use <tt>round</tt>. Here we get no decimals at all. </p><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);">round(x)</pre><pre style="font-style:oblique;">ans = 1
</pre><p>There are many ways to get the number of decimals you want. Here's one way to round to 3 decimals.</p><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);">round(x*1000)/1000</pre><pre style="font-style:oblique;">ans = 1.235000000000000
</pre><p>Here's another way.</p><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);">sprintf(<span style="color:#A020F0;">'%0.3f'</span>,x)</pre><pre style="font-style:oblique;">ans =
1.235
</pre><p>And another. In this case, using the "easy" way to specify the format, you need to know how many integral digits there are as well. </p><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);">str2num(num2str(x,4))</pre><pre style="font-style:oblique;">ans = 1.235000000000000
</pre><h3>Tools for Rounding Solutions<a rel="nofollow" name="7"></a></h3> <p>There are a lot of tools for helping you round numbers. The functions I list here for MATLAB form the basis of many, if not all, of the specific solutions. </p> <p>MATLAB</p> <div> <ul> <li><a rel="nofollow" target="_blank" href="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/round.html"><tt>round</tt></a></li> <li><a rel="nofollow" target="_blank" href="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/fix.html"><tt>fix</tt></a></li> <li><a rel="nofollow" target="_blank" href="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/floor.html"><tt>floor</tt></a></li> <li><a rel="nofollow" target="_blank" href="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/ceil.html"><tt>ceil</tt></a></li> <li><a rel="nofollow" target="_blank" href="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/sprintf.html"><tt>sprintf</tt></a></li> </ul> </div> <p>Mapping Toolbox</p> <div> <ul> <li><a rel="nofollow" target="_blank" href="http://www.mathworks.com/access/helpdesk/help/toolbox/map/roundn.html"><tt>roundn</tt></a></li> </ul> </div> <p>File Exchange Rounding Tools</p> <div> <ul> <li><a rel="nofollow" target="_blank" href="http://www.mathworks.com/matlabcentral/fileexchange/?term=round+decimal">Search : 'round decimal'</a></li> <li><a rel="nofollow" target="_blank" href="http://www.mathworks.com/matlabcentral/fileexchange/24213">Solution: round to power</a></li> <li><a rel="nofollow" target="_blank" href="http://www.mathworks.com/matlabcentral/fileexchange/23949">Solution: round to significant figures</a></li> </ul> </div><pre style="background:#F9F7F3;padding:10px;border:1px solid rgb(200,200,200);"><span style="color:#228B22;">% N= num2str(X,SF);</span>
<span style="color:#228B22;">% N= str2num(N);</span></pre><h3>Question for You<a rel="nofollow" name="9"></a></h3> <p>When you round values, do you want this for display only, or wanted for calculations? Some applications I can think of might include processing data that has a smaller number of bits of precision to start with. What applications do you need rounding for in your calculations? Post <a rel="nofollow" target="_blank" href="http://blogs.mathworks.com/loren/?p=197#respond">here</a> with your thoughts. </p><p style="text-align:right;font-size:xx-small;font-weight:lighter;font-style:italic;color:gray;"><br /><a rel="nofollow"><span style="font-size:x-small;font-style:italic;">Get the MATLAB code <noscript>(requires JavaScript)</noscript></span></a><br /><br /> Published with MATLAB&reg; 7.8<br /></p>
</div>
<img src="http://feeds.feedburner.com/~r/mathworks/loren/~4/Mq6sv7LgnHE" height="1" width="1"/>]]></content:encoded>
      </item>
      <item>
         <title>BEEP, Simulink versus MATLAB</title>
         <link>http://feedproxy.google.com/~r/SethOnSimulink/~3/72Lcyo0RZXE/</link>
         <description>Did you ever notice that a BEEP in Simulink means something
different from a BEEP in MATLAB? BEEP, What BEEP? What I’m talking about is that bell character you sometimes
hear. In older version of MATLAB (Pre R14), you could actually display a beep
on the screen. &amp;#62;&amp;#62; fprintf('&amp;#92;a') &amp;#62;&amp;#62; disp(char(7)) In more recent version, the command window doesn’t display
the BEEP character. [...]</description>
         <guid isPermaLink="false">http://blogs.mathworks.com/seth/2009/08/28/beep-simulink-versus-matlab/</guid>
         <pubDate>Fri, 28 Aug 2009 14:44:05 -0700</pubDate>
         <content:encoded><![CDATA[<p>Did you ever notice that a BEEP in Simulink means something
different from a BEEP in MATLAB?</p> <p><strong>BEEP, What BEEP?</strong></p> <p> What I’m talking about is that bell character you sometimes
hear. In older version of MATLAB (Pre R14), you could actually display a beep
on the screen. </p> <code style="font-size:11pt;"><span style='font-size:12.0pt;font-family:"Courier New";color:black;'>&gt;&gt; fprintf('&#92;a')</span><br /> <span style='font-size:12.0pt;font-family:"Courier New";color:black;'>&gt;&gt; disp(char(7))</span></code> <p>In more recent version, the command window doesn’t display
the BEEP character. Instead, you can call the function <a rel="nofollow"
 target="_blank" href="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/beep.html">BEEP</a>.</p> <code style="font-size:11pt;"><span style='font-size:12.0pt;font-family:"Courier New";color:black;'>&gt;&gt; beep</span></code> <p>You hear it under different circumstances for Simulink
versus MATLAB.</p> <p><strong>MATLAB BEEP == Error</strong></p> <p>In MATLAB, the BEEP alerts you to an error. Sometimes you
get it because your calling syntax is wrong, sometimes when the tab completion can’t
find anything. In MATLAB, BEEP is bad.</p> <code style="font-size:11pt;"><span style='font-size:12.0pt;font-family:"Courier New";color:black;'>&gt;&gt; plot(x,y</span><br /> <span style='font-size:12.0pt;font-family:"Courier New";color:red;'>??? plot(x,y</span><br /> <span style='font-size:12.0pt;font-family:"Courier New";color:red;'> |</span><br /> <span style='font-size:12.0pt;font-family:"Courier New";color:red;'>Error: Expression or statement is incorrect--possibly<br /> unbalanced
(, {, or [.</span></code> <p><strong>Simulink BEEP == Done</strong></p> <p>In Simulink, the BEEP happens when your simulation is
finished. It is a beautiful sound. The BEEP is an alert to tell you the work
is done. The fruit of your simulation is ready to harvest. It is time to
review your results. In Simulink, BEEP is a good sound.</p> <code style="font-size:11pt;"><span style='font-size:12.0pt;font-family:"Courier New";color:black;'>&gt;&gt; vdp</span><br />
<span style='font-size:12.0pt;font-family:"Courier New";color:black;'>&gt;&gt; set_param(bdroot,</span><span style='font-size:12.0pt;font-family:"Courier New";color:#A020F0;'>'SimulationCommand'</span><span
 style='font-size:12.0pt;font-family:"Courier New";color:black;'>,</span><span
 style='font-size:12.0pt;font-family:"Courier New";color:#A020F0;'>'start'</span><span
 style='font-size:12.0pt;font-family:"Courier New";color:black;'>)</span></code> <p><img src="http://blogs.mathworks.com/images/seth/2009Q3/vdpBEEP.png" alt="The VDP model in Simulink"></p> <p>Leave your comments, <a rel="nofollow"
 target="_blank" href="http://blogs.mathworks.com/seth/?p=64&amp;#comment">after the BEEP</a>. (THANK YOU Jeannette for alerting me to the difference.)</p>
<img src="http://feeds.feedburner.com/~r/SethOnSimulink/~4/72Lcyo0RZXE" height="1" width="1"/>]]></content:encoded>
      </item>
      <item>
         <title>A Better If-Else Construct</title>
         <link>http://feedproxy.google.com/~r/SethOnSimulink/~3/hGzYnCJm9PI/</link>
         <description>In a previous post, I answered a question about how
to model an If-Else behavior. Here I will restate the algorithm I want to create: if(sel==0)
out = 2*in1;
elseif (sel==1)
out = 3*in2; The first answer I gave relied upon a Switch block and the Conditional
Input Branch Execution optimization to get an efficient If-Else construct
in the model. While this works, [...]</description>
         <guid isPermaLink="false">http://blogs.mathworks.com/seth/2009/08/20/a-better-if-else-construct/</guid>
         <pubDate>Wed, 19 Aug 2009 18:55:12 -0700</pubDate>
         <content:encoded><![CDATA[<style>
<!-- _filtered {font-family:"Cambria Math";panose-1:2 4 5 3 5 4 6 3 2 4;}
 _filtered {font-family:Calibri;panose-1:2 15 5 2 2 2 4 3 2 4;}
 _filtered {font-family:Tahoma;panose-1:2 11 6 4 3 5 4 4 2 4;}/* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {margin-top:0in;margin-right:0in;margin-bottom:10.0pt;margin-left:0in;line-height:115%;font-size:11.0pt;font-family:"Calibri", "sans-serif";}
a:link, span.MsoHyperlink {color:blue;text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed {color:purple;text-decoration:underline;}
pre {margin:0in;margin-bottom:.0001pt;font-size:10.0pt;font-family:"Courier New";color:#1122AA;}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate {margin:0in;margin-bottom:.0001pt;font-size:8.0pt;font-family:"Tahoma", "sans-serif";}
span.BalloonTextChar {font-family:"Tahoma", "sans-serif";}
span.HTMLPreformattedChar {font-family:"Courier New";color:#1122AA;}
span.ln1 {color:#888888;font-style:italic;}
span.ct1 {color:#117755;font-style:italic;}
span.kw1 {color:#112266;}
.MsoPapDefault {margin-bottom:10.0pt;line-height:115%;}
 _filtered {margin:1.0in 1.0in 1.0in 1.0in;}
div.Section1 {}
-->
</style><p>In a previous post, I answered a question about <a rel="nofollow"
 target="_blank" href="http://blogs.mathworks.com/seth/2009/06/02/the-if-else-construct-in-models/">how
to model an If-Else behavior</a>. Here I will restate the algorithm I want to create:</p> <p><em>if(sel==0)<br />
out = 2*in1;<br />
elseif (sel==1)<br />
out = 3*in2;</em></p> <p>The first answer I gave relied upon a Switch block and the <em>Conditional
Input Branch Execution</em> optimization to get an efficient If-Else construct
in the model. While this works, I don’t like reliance on an optimization to
provide good behavior. Sometimes, small changes to the model prevent Simulink
from applying an optimization. I think it is best to implement requirements explicitly. In this post, I want to show you a way to model explicitly an If-Else conditional
execution behavior.</p> <p><strong>Conditionally Executed Subsystems and Merge</strong></p> <p>The If-Else construct requires decision logic to control the
execution of algorithm contained within the expression. One way to do this is
using the If block (from the Ports &amp; Subsystems library), combined with the
If Action Subsystem. The If Action Subsystem executes based on the conditional
expression in the If block. If you have used Function Call subsystems, this is
very similar.</p> <p><img src="http://blogs.mathworks.com/images/seth/2009Q3/ifActionConstruct.png" alt="The If Else, Else If, Action construct in Simulink blocks."></p> <p>The If block provides control over If and ElseIf conditions,
and there is even an option to provide an Else signal.</p> <p><img src="http://blogs.mathworks.com/images/seth/2009Q3/ifBlockParameters.png" alt="The Simulink If Block parameters."></p> <p>This model will give you the conditional execution of the
two subsystem, however, the subsystems write their outputs to separate signals. How do you get two subsystem to write to the same signal?</p> <p><strong>Merge the Signals</strong></p> <p>The Merge block provides a way for both subsystems to write
to the same signal.</p> <p><img src="http://blogs.mathworks.com/images/seth/2009Q3/MergeSignals.png" alt="The Merge Block provides a way to specify that multiple signal write to the same memory location."></p> <p>In many ways, the Merge block doesn’t behave like a block
with the traditional input/output relationship. I think of it more like a
jumper across multiple wires. The merge block specifies that all signals
connected to it have the same value and actually share the same memory. This
is the programming practice of specifying multiple writers to the same
variable.</p> <p><strong>Generated Code with Merge</strong></p> <p>The code generated from the above model looks a lot like our
original algorithm.</p> <code style="font-size:12pt;"><span class="ln1"> 34 </span> <span class="ct1">/* If: '&lt;Root&gt;/If' incorporates:</span><br /><span
 class="ln1"> 35 </span><span class="ct1"> * ActionPort: '&lt;S1&gt;/Action Port'</span><br /><span
 class="ln1"> 36 </span><span class="ct1"> * ActionPort: '&lt;S2&gt;/Action Port'</span><br /><span
 class="ln1"> 37 </span><span class="ct1"> * Inport: '&lt;Root&gt;/In3'</span><br /><span
 class="ln1"> 38 </span><span class="ct1"> * SubSystem: '&lt;Root&gt;/If Action Subsystem'</span><br /><span
 class="ln1"> 39 </span><span class="ct1"> * SubSystem: '&lt;Root&gt;/If Action Subsystem1'</span><br /><span
 class="ln1"> 40 </span><span class="ct1"> */</span><br /><span
 class="ln1"> 41 </span> <span class="kw1">if</span> (sel == 0.0) <strong>{</strong><br /><span
 class="ln1"> 42 </span> <span class="ct1">/* Gain: '&lt;S1&gt;/Gain' incorporates:</span><br /><span
 class="ln1"> 43 </span><span class="ct1"> * Inport: '&lt;Root&gt;/In1'</span><br /><span
 class="ln1"> 44 </span><span class="ct1"> */</span><br /><span
 class="ln1"> 45 </span> out = 2.0 * u1;<br /><span class="ln1"> 46 </span> <strong>}</strong> <span
 class="kw1">else</span> <strong>{</strong><br /><span class="ln1"> 47 </span> <span
 class="kw1">if</span> (sel == 1.0) <strong>{</strong><br /><span class="ln1"> 48 </span> <span
 class="ct1">/* Gain: '&lt;S2&gt;/Gain' incorporates:</span><br /><span
 class="ln1"> 49 </span><span class="ct1"> * Inport: '&lt;Root&gt;/In2'</span><br /><span
 class="ln1"> 50 </span><span class="ct1"> */</span><br /><span
 class="ln1"> 51 </span> out = 3.0 * u2;<br /><span class="ln1"> 52 </span> <strong>}</strong><br /><span
 class="ln1"> 53 </span> <strong>}</strong></code> <p><strong>Correct use of Merge</strong></p> <p>Because Merge blocks are a memory specification rather than
an algorithmic construct, there are some <a rel="nofollow"
 target="_blank" href="http://www.mathworks.com/access/helpdesk/help/toolbox/simulink/slref/merge.html">guidelines
for using merge blocks</a>. The documentation shows some correct and incorrect
usage patterns. If you use merge block in your model, I suggest you run the <a rel="nofollow"
 target="_blank" href="http://www.mathworks.com/access/helpdesk/help/toolbox/simulink/slref/bq6d4aa-1.html#bragjl8-1">Model
Advisor Check for proper Merge block usage</a>.</p> <p><strong>Now it’s your turn</strong></p> <p>Do you use the Merge block in your models? Leave a <a rel="nofollow"
 target="_blank" href="http://blogs.mathworks.com/seth/?p=63&amp;#comment">comment here</a> and
share your experience.</p>
<img src="http://feeds.feedburner.com/~r/SethOnSimulink/~4/hGzYnCJm9PI" height="1" width="1"/>]]></content:encoded>
      </item>
   </channel>
</rss>
<!-- fe12.pipes.sp1.yahoo.com uncompressed/chunked Sun Nov 22 03:47:35 PST 2009 -->
