<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/164609</link>
    <title>MATLAB Central Newsreader - A simple question about FOR</title>
    <description>Feed for thread: A simple question about FOR</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2012 by MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Tue, 26 Feb 2008 18:20:41 -0500</pubDate>
      <title>A simple question about FOR</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/164609#417484</link>
      <author>Kamil</author>
      <description>Dear Colleagues,&lt;br&gt;
&lt;br&gt;
I am wondering, if there was a simple way to suppress 'for' command in &lt;br&gt;
MATLAB.&lt;br&gt;
This would force students to use smarter solutions than just a lot of &lt;br&gt;
for loops and waiting :)&lt;br&gt;
If You have some hint how to do it in ver.2007b, let me know.&lt;br&gt;
Best Regards&lt;br&gt;
Kamil</description>
    </item>
    <item>
      <pubDate>Tue, 26 Feb 2008 18:33:02 -0500</pubDate>
      <title>Re: A simple question about FOR</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/164609#417486</link>
      <author>David </author>
      <description>Kamil &amp;lt;milka-wywal@to.free.of.pl&amp;gt; wrote in message &lt;br&gt;
&amp;lt;fq1lcs$t07$1@atlantis.news.tpi.pl&amp;gt;...&lt;br&gt;
&amp;gt; Dear Colleagues,&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; I am wondering, if there was a simple way to &lt;br&gt;
suppress 'for' command in &lt;br&gt;
&amp;gt; MATLAB.&lt;br&gt;
&amp;gt; This would force students to use smarter solutions than &lt;br&gt;
just a lot of &lt;br&gt;
&amp;gt; for loops and waiting :)&lt;br&gt;
&amp;gt; If You have some hint how to do it in ver.2007b, let me &lt;br&gt;
know.&lt;br&gt;
&amp;gt; Best Regards&lt;br&gt;
&amp;gt; Kamil&lt;br&gt;
&lt;br&gt;
class policy??? -10 points for every 'for' in an &lt;br&gt;
assignment.</description>
    </item>
    <item>
      <pubDate>Tue, 26 Feb 2008 18:47:19 -0500</pubDate>
      <title>Re: A simple question about FOR</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/164609#417488</link>
      <author>Loren Shure</author>
      <description>In article &amp;lt;fq1m0u$qlo$1@fred.mathworks.com&amp;gt;, dave@bigcompany.com &lt;br&gt;
says...&lt;br&gt;
&amp;gt; Kamil &amp;lt;milka-wywal@to.free.of.pl&amp;gt; wrote in message &lt;br&gt;
&amp;gt; &amp;lt;fq1lcs$t07$1@atlantis.news.tpi.pl&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; Dear Colleagues,&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; I am wondering, if there was a simple way to &lt;br&gt;
&amp;gt; suppress 'for' command in &lt;br&gt;
&amp;gt; &amp;gt; MATLAB.&lt;br&gt;
&amp;gt; &amp;gt; This would force students to use smarter solutions than &lt;br&gt;
&amp;gt; just a lot of &lt;br&gt;
&amp;gt; &amp;gt; for loops and waiting :)&lt;br&gt;
&amp;gt; &amp;gt; If You have some hint how to do it in ver.2007b, let me &lt;br&gt;
&amp;gt; know.&lt;br&gt;
&amp;gt; &amp;gt; Best Regards&lt;br&gt;
&amp;gt; &amp;gt; Kamil&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; class policy??? -10 points for every 'for' in an &lt;br&gt;
&amp;gt; assignment.&lt;br&gt;
&amp;gt; &lt;br&gt;
&lt;br&gt;
My thesis advisor used to deduct 5 points :-)&lt;br&gt;
&lt;br&gt;
-- &lt;br&gt;
Loren&lt;br&gt;
&lt;a href=&quot;http://blogs.mathworks.com/loren/&quot;&gt;http://blogs.mathworks.com/loren/&lt;/a&gt;</description>
    </item>
    <item>
      <pubDate>Tue, 26 Feb 2008 19:56:15 -0500</pubDate>
      <title>Re: A simple question about FOR</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/164609#417510</link>
      <author>roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)</author>
      <description>In article &amp;lt;fq1lcs$t07$1@atlantis.news.tpi.pl&amp;gt;,&lt;br&gt;
Kamil  &amp;lt;milka-wywal@to.free.of.pl&amp;gt; wrote:&lt;br&gt;
&lt;br&gt;
&amp;gt;I am wondering, if there was a simple way to suppress 'for' command in &lt;br&gt;
&amp;gt;MATLAB.&lt;br&gt;
&amp;gt;This would force students to use smarter solutions than just a lot of &lt;br&gt;
&amp;gt;for loops and waiting :)&lt;br&gt;
&lt;br&gt;
Sometimes using a 'for' or 'while' loop *is* the most efficient way.&lt;br&gt;
&lt;br&gt;
For example a couple of weeks ago, I had a case in which the&lt;br&gt;
standard matlab method of writing a section of code was roughly&lt;br&gt;
&lt;br&gt;
[X,Y] = ndgrid(A,B);&lt;br&gt;
answer = sum(X &amp;lt; Y);&lt;br&gt;
&lt;br&gt;
Now allow A and B to grow to roughly 1200 elements each, and&lt;br&gt;
call this code 100,000 times, and these two lines of code took&lt;br&gt;
approximately 26.13 minutes to execute.&lt;br&gt;
&lt;br&gt;
After some thought, I replaced this short code with a 'while'&lt;br&gt;
loop that took noticably more coding lines, but was linear in the&lt;br&gt;
size of A (and independant of the size of B). With the same dataset,&lt;br&gt;
calling the same 100,000 times, the replacement code took 2.39 seconds&lt;br&gt;
total to execute.&lt;br&gt;
&lt;br&gt;
Now, if I were to turn in that 'while' solution that was ~50 times&lt;br&gt;
faster than anyone else achieved using matlab vectorized operations,&lt;br&gt;
would you fail me on the assignment for not using a sufficiently&lt;br&gt;
&quot;smart&quot; solution?&lt;br&gt;
-- &lt;br&gt;
&amp;nbsp;&amp;nbsp;&quot;The beauties of conception are always superior to those of&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;expression.&quot;                               -- Walter J. Phillips</description>
    </item>
  </channel>
</rss>

