[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
find command sometimes doesn't work in script
From: |
Lidia Bressan |
Subject: |
find command sometimes doesn't work in script |
Date: |
Thu, 12 Nov 2009 11:10:51 +0100 |
Sure, here I write all the information I was missing in the last email.
I use GNU Octave, version 3.2.2. I'm not sure what you mean with octave
configuration.
Any result:
octave:105> any ((1:0.05:5) == 2.05)
ans = 0
and also
octave:116> a=(1:0.05:5).*100
octave:117> any (a == 205)
ans = 0
Is there a way to go around a precision issue?
matrix BB:
1.0000 6.0000 60.0000 10.0000 1.0000 1219.0833
1.0000 6.0000 60.0000 10.0000 1.0000 2109.0833
1.0000 6.0000 60.0000 10.0000 1.0000 5099.0833
1.0000 6.0000 60.0000 10.0000 1.0500 1219.0833
1.0000 6.0000 60.0000 10.0000 1.0500 2109.0833
1.0000 6.0000 60.0000 10.0000 1.0500 5099.0833
1.0000 6.0000 60.0000 10.0000 1.1000 1219.0833
1.0000 6.0000 60.0000 10.0000 1.1000 2109.0833
1.0000 6.0000 60.0000 10.0000 1.1000 5099.0833
1.0000 6.0000 60.0000 10.0000 1.1500 1219.0833
1.0000 6.0000 60.0000 10.0000 1.1500 2109.0833
1.0000 6.0000 60.0000 10.0000 1.1500 5099.0833
1.0000 6.0000 60.0000 10.0000 1.2000 1219.0833
1.0000 6.0000 60.0000 10.0000 1.2000 2109.0833
1.0000 6.0000 60.0000 10.0000 1.2000 5099.0833
1.0000 6.0000 60.0000 10.0000 1.2500 1219.0833
1.0000 6.0000 60.0000 10.0000 1.2500 2109.0833
1.0000 6.0000 60.0000 10.0000 1.2500 5099.0833
1.0000 6.0000 60.0000 10.0000 1.3000 1219.0833
1.0000 6.0000 60.0000 10.0000 1.3000 2109.0833
1.0000 6.0000 60.0000 10.0000 1.3000 5099.0833
1.0000 6.0000 60.0000 10.0000 1.3500 1219.0833
1.0000 6.0000 60.0000 10.0000 1.3500 2109.0833
1.0000 6.0000 60.0000 10.0000 1.3500 5099.0833
1.0000 6.0000 60.0000 10.0000 1.4000 1219.0833
1.0000 6.0000 60.0000 10.0000 1.4000 2109.0833
1.0000 6.0000 60.0000 10.0000 1.4000 5099.0833
1.0000 6.0000 60.0000 10.0000 1.4500 16.0833
1.0000 6.0000 60.0000 10.0000 1.4500 209.0833
1.0000 6.0000 60.0000 10.0000 1.4500 555.0833
1.0000 6.0000 60.0000 10.0000 1.5000 16.0833
1.0000 6.0000 60.0000 10.0000 1.5000 209.0833
1.0000 6.0000 60.0000 10.0000 1.5000 555.0833
1.0000 6.0000 60.0000 10.0000 1.5500 16.0833
1.0000 6.0000 60.0000 10.0000 1.5500 209.0833
1.0000 6.0000 60.0000 10.0000 1.5500 555.0833
1.0000 6.0000 60.0000 10.0000 1.6000 209.0833
1.0000 6.0000 60.0000 10.0000 1.6000 1219.0833
1.0000 6.0000 60.0000 10.0000 1.6000 2109.0833
1.0000 6.0000 60.0000 10.0000 1.6500 209.0833
1.0000 6.0000 60.0000 10.0000 1.6500 2109.0833
1.0000 6.0000 60.0000 10.0000 1.6500 2109.0833
1.0000 6.0000 60.0000 10.0000 1.7000 209.0833
1.0000 6.0000 60.0000 10.0000 1.7000 2109.0833
1.0000 6.0000 60.0000 10.0000 1.7000 2109.0833
1.0000 6.0000 60.0000 10.0000 1.7500 209.0833
1.0000 6.0000 60.0000 10.0000 1.7500 2109.0833
1.0000 6.0000 60.0000 10.0000 1.7500 2109.0833
1.0000 6.0000 60.0000 10.0000 1.8000 209.0833
1.0000 6.0000 60.0000 10.0000 1.8000 2109.0833
1.0000 6.0000 60.0000 10.0000 1.8000 2109.0833
1.0000 6.0000 60.0000 10.0000 1.8500 209.0833
1.0000 6.0000 60.0000 10.0000 1.8500 2109.0833
1.0000 6.0000 60.0000 10.0000 1.8500 2109.0833
1.0000 6.0000 60.0000 10.0000 1.9000 -5000.0000
1.0000 6.0000 60.0000 10.0000 1.9500 -5000.0000
1.0000 6.0000 60.0000 10.0000 2.0000 -5000.0000
1.0000 6.0000 60.0000 10.0000 2.0500 -5000.0000
1.0000 6.0000 60.0000 10.0000 2.1000 -5000.0000
1.0000 6.0000 60.0000 10.0000 2.1500 -5000.0000
1.0000 6.0000 60.0000 10.0000 2.2000 -5000.0000
1.0000 6.0000 60.0000 10.0000 2.2500 -5000.0000
1.0000 6.0000 60.0000 10.0000 2.3000 -5000.0000
1.0000 6.0000 60.0000 10.0000 2.3500 -5000.0000
1.0000 6.0000 60.0000 10.0000 2.4000 -5000.0000
1.0000 6.0000 60.0000 10.0000 2.4500 -5000.0000
1.0000 6.0000 60.0000 10.0000 2.5000 -5000.0000
1.0000 6.0000 60.0000 10.0000 2.5500 -5000.0000
1.0000 6.0000 60.0000 10.0000 2.6000 -5000.0000
1.0000 6.0000 60.0000 10.0000 2.6500 -5000.0000
1.0000 6.0000 60.0000 10.0000 2.7000 -5000.0000
1.0000 6.0000 60.0000 10.0000 2.7500 -5000.0000
1.0000 6.0000 60.0000 10.0000 2.8000 -5000.0000
1.0000 6.0000 60.0000 10.0000 2.8500 -5000.0000
1.0000 6.0000 60.0000 10.0000 2.9000 -5000.0000
1.0000 6.0000 60.0000 10.0000 2.9500 -5000.0000
1.0000 6.0000 60.0000 10.0000 3.0000 -5000.0000
1.0000 6.0000 60.0000 10.0000 3.0500 -5000.0000
1.0000 6.0000 60.0000 10.0000 3.1000 -5000.0000
1.0000 6.0000 60.0000 10.0000 3.1500 -5000.0000
1.0000 6.0000 60.0000 10.0000 3.2000 -5000.0000
1.0000 6.0000 60.0000 10.0000 3.2500 -5000.0000
1.0000 6.0000 60.0000 10.0000 3.3000 -5000.0000
1.0000 6.0000 60.0000 10.0000 3.3500 -5000.0000
1.0000 6.0000 60.0000 10.0000 3.4000 -5000.0000
1.0000 6.0000 60.0000 10.0000 3.4500 -5000.0000
1.0000 6.0000 60.0000 10.0000 3.5000 -5000.0000
1.0000 6.0000 60.0000 10.0000 3.5500 -5000.0000
1.0000 6.0000 60.0000 10.0000 3.6000 -5000.0000
1.0000 6.0000 60.0000 10.0000 3.6500 -5000.0000
1.0000 6.0000 60.0000 10.0000 3.7000 -5000.0000
1.0000 6.0000 60.0000 10.0000 3.7500 -5000.0000
1.0000 6.0000 60.0000 10.0000 3.8000 -5000.0000
1.0000 6.0000 60.0000 10.0000 3.8500 -5000.0000
1.0000 6.0000 60.0000 10.0000 3.9000 -5000.0000
1.0000 6.0000 60.0000 10.0000 3.9500 -5000.0000
1.0000 6.0000 60.0000 10.0000 4.0000 -5000.0000
1.0000 6.0000 60.0000 10.0000 4.0500 -5000.0000
1.0000 6.0000 60.0000 10.0000 4.1000 -5000.0000
1.0000 6.0000 60.0000 10.0000 4.1500 -5000.0000
1.0000 6.0000 60.0000 10.0000 4.2000 -5000.0000
1.0000 6.0000 60.0000 10.0000 4.2500 -5000.0000
1.0000 6.0000 60.0000 10.0000 4.3000 -5000.0000
1.0000 6.0000 60.0000 10.0000 4.3500 -5000.0000
1.0000 6.0000 60.0000 10.0000 4.4000 -5000.0000
1.0000 6.0000 60.0000 10.0000 4.4500 -5000.0000
1.0000 6.0000 60.0000 10.0000 4.5000 -5000.0000
1.0000 6.0000 60.0000 10.0000 4.5500 -5000.0000
1.0000 6.0000 60.0000 10.0000 4.6000 -5000.0000
1.0000 6.0000 60.0000 10.0000 4.6500 -5000.0000
1.0000 6.0000 60.0000 10.0000 4.7000 -5000.0000
1.0000 6.0000 60.0000 10.0000 4.7500 -5000.0000
1.0000 6.0000 60.0000 10.0000 4.8000 -5000.0000
1.0000 6.0000 60.0000 10.0000 4.8500 -5000.0000
1.0000 6.0000 60.0000 10.0000 4.9000 -5000.0000
1.0000 6.0000 60.0000 10.0000 4.9500 -5000.0000
1.0000 6.0000 60.0000 10.0000 5.0000 -5000.0000
Thanks
Lidia
Il giorno mer, 11/11/2009 alle 21.39 +0100, Jaroslav Hajek ha scritto:
>
>
> On Wed, Nov 11, 2009 at 6:12 PM, Lidia Bressan
> <address@hidden> wrote:
> I am havig problems with find.
>
> I use ubuntu and I just upgraded to 9.10 Karmic Koala ubuntu.
>
> I use 'find' to look for a particular value in a matrix,
> inside a for
> loop.
> Values of matrix B column 5 go from 1.0 to 5.0 (or to 4.0)
> with 0.05
> step. Some values might be repeated.
> I want to check where in matrix B, column 5 there are more
> times the
> same value. In that case, I want to select the row with the
> smallest
> positive value of column 6, and compose in this way matrix C.
>
> The problem is that for some values 'find' in script doesn't
> work and
> return an empty vector, while in terminal I get the right
> result.
> Is there an error in my for loop or what could be the problem?
> Matrix B
> is composed reading some files and then rearranging it.
>
> Here after I write the code I use.
>
> Do you have any suggestions, please?
>
>
>
> In script:
>
> C=[];
> if( (max(BB(:,5))-min(BB(:,5)))/0.05 +1!=size(BB,1))
>
> for jj=1.0000:0.0500:max(BB(:,5))
> clear doubleval; doubleval=find(BB(:,5)==jj);
> if(size(doubleval,1)>1)
> clear rbay rbax
> mval=min(max(BB(doubleval,6),0));
> mvalx=find(BB(doubleval,6)==mval);
> C=[C; BB(doubleval(mvalx),:)];
> elseif(size(doubleval,1)==1)
> C=[C; BB(doubleval,:)];
> elseif(size(doubleval,1)==0)
> disp(jj)
> endif
> endfor
> else
> C=BB;
> endif
>
>
> 1.6500
> 1.9000
> 2.0500
> 2.3000
> 2.5500
> 2.8000
> 3.0500
> 3.3000
> 3.4000
> 3.5500
> 3.6500
> 3.8000
> 3.9000
> 4.1000
> 4.3500
> 4.6000
> 4.8500
>
>
> In terminal:
>
> octave:102> jj=2.05;
> octave:103> doubleval=find(BB(:,5)==jj)
> doubleval = 58
>
> Lidia Bressan
>
> this looks like precision issue. What does
>
> any ((1:0.05:5) == 2.05)
>
> give you? You should be aware that numbers like 2.05 cannot be
> represented exactly by computer floating point types.
>
> In any case it would help if you submitted a more complete report,
> including your Octave version & configuration, and if possible also
> the matrix BB that shows the problem.
>
> hth
>
> --
> RNDr. Jaroslav Hajek
> computing expert & GNU Octave developer
> Aeronautical Research and Test Institute (VZLU)
> Prague, Czech Republic
> url: www.highegg.matfyz.cz