Scilab Website | Contribute with GitLab | Mailing list archives | ATOMS toolboxes
Scilab Online Help
2023.1.0 - 日本語


find

論理値ベクトルまたは行列のtrue要素の添え字を見つける

呼び出し手順

ii = find(x)
[i1,i2,..] = find(x)
.. = find(x, nmax)

引数

x

ブールまたは数値のベクトル、行列、または超行列. ゼロ以外の数値は%Tと見なされます. スパース行列が受け入れられます.

nmax

返される添え字の最大数を指定する整数. デフォルト値は"全て"を意味する -1 です. このオプションは,全ての添え字の探索を避け,処理効率を改善するために 使用できます.

ii

row vector of linearized indices of %T or non-zero elements, or empty matrix [].

i1, i2, ..

row vectors of directional indices, or empty matrix []

説明

x が論理値の場合,

ii=find(x)x(i)が "true"の添字iのベクトルを返します. trueとなる要素がみつからない場合,空行列が返されます.

[i1,i2,..]=find(x) は, x(i1(n),i2(n),..)が "true" の 添字i1 (行の場合) および i2 (列の場合),..のベクトルを返します. trueとなる要素がみつからない場合, i1,i2, ...の空行列を返します.

x が標準行列またはハイパー行列の場合, find(x)find(x<>0) と解釈されます.

find([])[]を返します.

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.

参照

  • vectorfind — locates occurences of a (wildcarded) vector in a matrix or hypermatrix
  • grep — 文字列のベクトルの中で指定した文字列に一致するかどうかを調べる
  • findobj — find an object with specified property
  • boolean — Scilab オブジェクト, 論理値(boolean)変数および演算子 & | ~
Report an issue
<< dsearch searchandsort gsort >>

Copyright (c) 2022-2024 (Dassault Systèmes)
Copyright (c) 2017-2022 (ESI Group)
Copyright (c) 2011-2017 (Scilab Enterprises)
Copyright (c) 1989-2012 (INRIA)
Copyright (c) 1989-2007 (ENPC)
with contributors
Last updated:
Mon May 22 12:43:09 CEST 2023