[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: for loop on decimal numbers fails.
From: |
Swiss_Knight |
Subject: |
Re: for loop on decimal numbers fails. |
Date: |
Tue, 19 Jul 2016 14:34:33 -0700 (PDT) |
Hi,
thanks for the fast reply, and yes, it was a typo, sorry.
Nice trick, it helps, but I still have a strange error :
A=[sort(repmat ([1:1:10]',[4,1])), repmat([5:5:20]',[10;1]), rand(40,1)];
A(:,1)=A(:,1)/10;
A(:,2)=A(:,2)/10;
I=0.1:0.1:1;
J=0.5:0.5:2;
for i_index=1:length(I);
i=I(i_index);
for j_index=1:length(J);
j=J(j_index);
A((find((A(:,1)==i))))
endfor;
endfor;
It fails for i=0.3 and i=0.7. (seems like a numerical computing issue ?!)
But if I define A this way with having the two first columns directly in the
right units :
A=[sort(repmat ([0.1:0.1:1]',[4,1])), repmat([0.5 1 1.5 2]',[10;1]),
rand(40,1)];
Everything is OK.
I can't understand...
Thanks a lot.
--
View this message in context:
http://octave.1599824.n4.nabble.com/for-loop-on-decimal-numbers-fails-tp4678664p4678671.html
Sent from the Octave - General mailing list archive at Nabble.com.