find
fornece os índices de elementos %T ou diferentes de zero
Seqüência de Chamamento
ii = find(x) [i1,i2,..] = find(x) .. = find(x, nmax)
Parâmetros
- x
- vetor, matriz ou hipermatriz de booleanos ou de números. Todos os números diferentes de zero são considerados como %T. Matrizes esparsas são aceitas. 
- nmax
- um inteiro fornecendo o número máximo de índices a serem retornados. o valor padrão é -1, que significa "todos". Esta opção pode ser usada por eficiência, para evitar uma busca por todos os índices. 
- ii
- vetor de linha de índices linearizados de elementos %T ou diferentes de zero, ou matriz vazia []. 
- i1, i2, ..
- vetores de linha de índices direcionais, ou matriz vazia []. 
Descrição
Se x é uma matriz booleana,
ii=find(x) retorna o vetor de índices
            i para os quais x(i) é "true"
            ("verdadeiro").Se nenhum elemento "true" for encontrado, retorna uma
            matriz vazia.
[i1,i2,..]=find(x) retorna vetores de índices
            i1 (para linhas) e i2 (para
            colunas),... tais que x(i1(n),i2(n),..) ié "true"
            ("verdadeiro"). Se nenhum elemento "true" for encontrado, retorna matrizes
            vazias em i1, i2, ...
Se x é uma matriz ou hipermatriz padrão
            find(x) é interpretado como
            find(x<>0)
find([]) retorna []
Exemplos
With input booleans:
A = [%F %T %T %F ; %T %F %F %T] find(A) find(A,2)
--> A = [%F %T %T %F ; %T %F %F %T] A = F T T F T F F T --> find(A) ans = 2. 3. 5. 8. --> find(A,2) ans = 2. 3.
With input numbers:
B = [0 -1 0 3 ; 0 -1 -0.4 0] find(B) [i, j] = find(B); [i' j']
--> B = [0 -1 0 3 ; 0 -1 -0.4 0] B = 0. -1. 0. 3. 0. -1. -0.4 0. --> find(B) ans = 3. 4. 6. 7. --> [i, j] = find(B); --> [i' j'] ans = 1. 2. 2. 2. 2. 3. 1. 4.
With an input hypermatrix of numbers:
E = grand(2,5,2,"uin",1,6) find(E < 4)
--> E = grand(2,5,2,"uin",1,6) E = (:,:,1) 1. 6. 5. 5. 4. 6. 5. 3. 4. 4. (:,:,2) 2. 4. 3. 6. 5. 5. 6. 6. 6. 4. --> find(E < 4) ans = 1. 6. 11. 15.
With an input numerical or boolean sparse matrix:
C = [0 3 7 0 9 0 0 4 0 0 5 0 6 0 1 0 3 8 ]; C = sparse(C); find(C) find(C, 4) // With input boolean sparse D = C > 4 full(D) find(D)
--> C = sparse(C);
--> find(C)
 ans  =
    3.    4.    5.    7.    9.    13.    14.    15.    18.
-->find(C, 4)
 ans  =
    3.    4.    5.    7.
--> // With input boolean sparse
--> D = C > 4
 D  =
(  3,  6) sparse boolean matrix
(  1,  3)   T
(  1,  5)   T
(  2,  5)   T
(  3,  1)   T
(  3,  6)   T
--> full(D)
 ans  =
  F F T F T F
  F F F F T F
  T F F F F T
-->find(D)
 ans  =
    3.    7.    13.    14.    18.
With the result of a boolean element-wise condition on texts
beers = ["Desperados", "Leffe", "Kronenbourg", "Heineken"]; find(beers == "Leffe") find(beers == "1664")
--> find(beers == "Leffe")
 ans  =
   2.
--> find(beers == "1664")
 ans  =
    []
Addressing selected elements:
// a) Through their linearized indices: H = [ 0 -2 -8 4 -5 -1 -2 2 -9 5 0 1 ]; L = H; L(find(L < 0)) = -10 // b) Directly through the array of their boolean status: L = H; L(L < 0) = -10
--> // a) Through their linearized indices: --> H = [ 0 -2 -8 4 -5 -1 > -2 2 -9 5 0 1 > ]; --> L = H; --> L(find(L < 0)) = -10 L = 0. -10. -10. 4. -10. -10. -10. 2. -10. 5. 0. 1. --> // b) Directly through the array of their boolean status: --> L = H; --> L(L < 0) = -10 L = 0. -10. -10. 4. -10. -10. -10. 2. -10. 5. 0. 1.
Ver Também
- vectorfind — locates occurences of a (wildcarded) vector in a matrix or hypermatrix
- grep — acha correspondências de um string em um vetor de strings
- findobj — find an object with specified property
- boolean — objetos Scilab: variáveis booleanas e operadores '&', '|' e '~'
| Report an issue | ||
| << dsearch | Search and sort | gsort >> |