[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: imbricated loops
From: |
Judd Storrs |
Subject: |
Re: imbricated loops |
Date: |
Fri, 5 Nov 2010 15:37:48 -0400 |
On Fri, Nov 5, 2010 at 3:25 PM, William Krekeler
<address@hidden> wrote:
> The error is likely in how the code interprets the statement as written. for
> (j=1:i-1) is likely interpreted as for (j=1:i) -1. The -1 is extra. I've run
> into this problem in Matlab before. Add explicit () around your arguments and
> see if it works.
Explicit parentheses shouldn't be necessary since ":" has lower
operator precedence than "-". In other words, "j=1:i-1" is defined to
be identical to "1:(i-1)". See:
http://www.gnu.org/software/octave/doc/interpreter/Operator-Precedence.html#Operator-Precedence
--judd