help-octave
[Top][All Lists]
Advanced

[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: Wed, 11 Nov 2009 18:12:17 +0100

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




reply via email to

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