<rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" version="2.0">
  <channel>
    <title>MaplePrimes - answers and comments on Question, Nested for loop with mod input</title>
    <link>http://www.mapleprimes.com/questions/144751-Nested-For-Loop-With-Mod-Input</link>
    <language>en-us</language>
    <copyright>2026 Maplesoft, A Division of Waterloo Maple Inc.</copyright>
    <generator>Maplesoft Document System</generator>
    <lastBuildDate>Tue, 09 Jun 2026 22:14:48 GMT</lastBuildDate>
    <pubDate>Tue, 09 Jun 2026 22:14:48 GMT</pubDate>
    <itunes:subtitle />
    <itunes:summary />
    <description>The latest answers and comments added to the Question, Nested for loop with mod input</description>
    <image>
      <url>http://www.mapleprimes.com/images/mapleprimeswhite.jpg</url>
      <title>MaplePrimes - answers and comments on Question, Nested for loop with mod input</title>
      <link>http://www.mapleprimes.com/questions/144751-Nested-For-Loop-With-Mod-Input</link>
    </image>
    <item>
      <title>Upper bounds of loops don't match</title>
      <link>http://www.mapleprimes.com/questions/144751-Nested-For-Loop-With-Mod-Input?ref=Feed:MaplePrimes:Nested for loop with mod input:Comments#answer144753</link>
      <itunes:summary>&lt;p&gt;In the Matlab, the upper bound of the inner loop is the index of the outer loop; whereas in the Maple, the two loops have the same upper bound. The closest matching Maple code to your Matlab is&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;for j from 1 to N do&lt;/strong&gt;&lt;br&gt;&lt;strong&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for i from irem(j-1,2) to j by 2 do&lt;/strong&gt;&lt;br&gt;&lt;strong&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dhat[i+1,j+1]:= 2*j&lt;/strong&gt;&lt;br&gt;&lt;strong&gt;&amp;nbsp;&amp;nbsp; end do&lt;/strong&gt;&lt;br&gt;&lt;strong&gt;end do;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;You can also use &lt;strong&gt;(j-1) mod 2&lt;/strong&gt;; I prefer &lt;strong&gt;irem &lt;/strong&gt;in this case.&lt;/p&gt;</itunes:summary>
      <description>&lt;p&gt;In the Matlab, the upper bound of the inner loop is the index of the outer loop; whereas in the Maple, the two loops have the same upper bound. The closest matching Maple code to your Matlab is&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;for j from 1 to N do&lt;/strong&gt;&lt;br&gt;&lt;strong&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for i from irem(j-1,2) to j by 2 do&lt;/strong&gt;&lt;br&gt;&lt;strong&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dhat[i+1,j+1]:= 2*j&lt;/strong&gt;&lt;br&gt;&lt;strong&gt;&amp;nbsp;&amp;nbsp; end do&lt;/strong&gt;&lt;br&gt;&lt;strong&gt;end do;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;You can also use &lt;strong&gt;(j-1) mod 2&lt;/strong&gt;; I prefer &lt;strong&gt;irem &lt;/strong&gt;in this case.&lt;/p&gt;</description>
      <guid>144753</guid>
      <pubDate>Mon, 18 Mar 2013 22:19:30 Z</pubDate>
      <itunes:author>Carl Love</itunes:author>
      <author>Carl Love</author>
    </item>
    <item>
      <title>Thank you that solved my problem.</title>
      <link>http://www.mapleprimes.com/questions/144751-Nested-For-Loop-With-Mod-Input?ref=Feed:MaplePrimes:Nested for loop with mod input:Comments#comment144754</link>
      <itunes:summary>&lt;p&gt;Thank you that solved my problem.&lt;/p&gt;</itunes:summary>
      <description>&lt;p&gt;Thank you that solved my problem.&lt;/p&gt;</description>
      <guid>144754</guid>
      <pubDate>Mon, 18 Mar 2013 23:00:50 Z</pubDate>
      <itunes:author>erdem</itunes:author>
      <author>erdem</author>
    </item>
  </channel>
</rss>