help-octave
[Top][All Lists]

## for loop on decimal numbers fails.

 From: Swiss_Knight Subject: for loop on decimal numbers fails. Date: Tue, 19 Jul 2016 09:59:51 -0700 (PDT)

```Hi,

if we loop on values which are not integers, it fails.

Here is an example :
A = [
0.1         0.5      2.0983
0.2           1      3.6153
0.3         1.5      7.4621
0.4           2      5.6493
];
I=0.1:0.1:0.4;
J=0.5:0.5:2;

for i=0.1:0.1,0.4
for j=0.5:0.5:2;
M(i,(find(J==j)))=[A((find((A(:,1)==i & A(:,2)==j))),3)];
endfor;
endfor;

=> returns :
/ans =          1
error: subscript indices must be either positive integers less than 2^31 or
logicals./

Outside the loops every part looks fine :
/(find(J==1.5))/ => 3  [it's OK]
/A((find((A(:,1)==i & A(:,2)==j))),3)/ => /ans =     2.0983/  [it's OK]

But :
/A((find((A(:,1)==0.2 & A(:,2)==1.5))),3)/ => /ans = [](0x1)/  [it's no more
OK... why?!]

Thanks.

--
View this message in context:
http://octave.1599824.n4.nabble.com/for-loop-on-decimal-numbers-fails-tp4678664.html
Sent from the Octave - General mailing list archive at Nabble.com.

```