help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

imbricated loops


From: Delphine Fitzenz
Subject: imbricated loops
Date: Fri, 5 Nov 2010 17:27:45 +0000

Hi!

It seems basic, but can-t find the reason for the bug in the FAQ or the manual.

Here goes:
EQ1, L1 and L2 are vectors of length 1000.

when I type 

EQ1(1)=0;
k=0;
for i=2:1000
for (j=1:i-1)
for (k=i+1:1000)
EQ1(i)+=L1(j)*L2(k)/(k-j);
endfor
endfor
 endfor
I get an error message at the 2nd for statement.

I tried another way, with a while loop, and then I get troubles before the second while (the equivalent of the 3rd for) when I need to initiate k to i.
It seems that octave does not want to evaluate the value of the counters. 

example:
octave-3.2.3:46> k=0;
octave-3.2.3:47> for i=2:1000
> j=1;
> while (j<i)
> k=i;
Display all 1595 possibilities? (y or n)
.nargin.                         invhilb
EDITOR                           ipermute
EQ1                    

Thanks for any suggestion. I am used to programming in C or C++ and thought that just for a quick verification of a computation I could do it directly with octave, but it does not seem that straightforward...

All the best,
Delphine.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]