1 <?xml version="1.0" encoding="UTF-8"?>
3 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
5 * Copyright (C) 2012 - 2016 - Scilab Enterprises
6 * Copyright (C) 2020 - Samuel GOUGEON
8 * This file is hereby licensed under the terms of the GNU GPL v2.0,
9 * pursuant to article 5.3.4 of the CeCILL v.2.1.
10 * This file was originally licensed under the terms of the CeCILL v2.1,
11 * and continues to be available under such terms.
12 * For more information, see the COPYING file which you should have received
13 * along with this program.
16 <refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"
17 xmlns:svg="http://www.w3.org/2000/svg" xmlns:ns5="http://www.w3.org/1999/xhtml"
18 xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook"
19 xmlns:scilab="http://www.scilab.org" xml:id="find" xml:lang="pt">
21 <refname>find</refname>
23 fornece os índices de elementos %T ou diferentes de zero
27 <title>Seqüência de Chamamento</title>
35 <title>Parâmetros</title>
41 vetor, matriz ou hipermatriz de booleanos ou de números.
42 Todos os números diferentes de zero são considerados como %T.
43 Matrizes esparsas são aceitas.
50 <para>um inteiro fornecendo o número máximo de índices a serem
51 retornados. o valor padrão é -1, que significa "todos". Esta opção
52 pode ser usada por eficiência, para evitar uma busca por todos os
61 vetor de linha de índices linearizados de elementos %T ou diferentes
62 de zero, ou matriz vazia [].
67 <term>i1, i2, ..</term>
70 vetores de linha de índices direcionais, ou matriz vazia [].
77 <title>Descrição</title>
79 Se <literal>x</literal> é uma matriz booleana,
82 <literal>ii=find(x)</literal> retorna o vetor de índices
83 <literal>i</literal> para os quais <literal>x(i)</literal> é "true"
84 ("verdadeiro").Se nenhum elemento "true" for encontrado, retorna uma
88 <literal>[i1,i2,..]=find(x)</literal> retorna vetores de índices
89 <literal>i1</literal> (para linhas) e <literal>i2</literal> (para
90 colunas),... tais que <literal>x(i1(n),i2(n),..)</literal> ié "true"
91 ("verdadeiro"). Se nenhum elemento "true" for encontrado, retorna matrizes
92 vazias em <literal>i1</literal>, <literal>i2</literal>, ...
95 Se <literal>x</literal> é uma matriz ou hipermatriz padrão
96 <literal>find(x)</literal> é interpretado como
97 <literal>find(x<>0)</literal>
100 <literal>find([])</literal> retorna <literal>[]</literal>
104 <title>Exemplos</title>
108 <programlisting role="example"><![CDATA[
109 A = [%F %T %T %F ; %T %F %F %T]
114 --> A = [%F %T %T %F ; %T %F %F %T]
130 <programlisting role="example"><![CDATA[
131 B = [0 -1 0 3 ; 0 -1 -0.4 0]
137 --> B = [0 -1 0 3 ; 0 -1 -0.4 0]
146 --> [i, j] = find(B);
155 With an input hypermatrix of numbers:
157 <programlisting role="example"><![CDATA[
158 E = grand(2,5,2,"uin",1,6)
162 --> E = grand(2,5,2,"uin",1,6)
176 With an input numerical or boolean sparse matrix:
178 <programlisting role="example"><![CDATA[
187 // With input boolean sparse
196 3. 4. 5. 7. 9. 13. 14. 15. 18.
202 --> // With input boolean sparse
205 ( 3, 6) sparse boolean matrix
223 With the result of a boolean element-wise condition on texts
225 <programlisting role="example"><![CDATA[
226 beers = ["Desperados", "Leffe", "Kronenbourg", "Heineken"];
227 find(beers == "Leffe")
228 find(beers == "1664")
231 --> find(beers == "Leffe")
235 --> find(beers == "1664")
240 Addressing selected elements:
242 <programlisting role="example"><![CDATA[
243 // a) Through their linearized indices:
244 H = [ 0 -2 -8 4 -5 -1
250 // b) Directly through the array of their boolean status:
255 --> // a) Through their linearized indices:
256 --> H = [ 0 -2 -8 4 -5 -1
260 --> L(find(L < 0)) = -10
262 0. -10. -10. 4. -10. -10.
263 -10. 2. -10. 5. 0. 1.
265 --> // b) Directly through the array of their boolean status:
269 0. -10. -10. 4. -10. -10.
270 -10. 2. -10. 5. 0. 1.
273 <refsection role="see also">
274 <title>Ver Também</title>
275 <simplelist type="inline">
277 <link linkend="vectorfind">vectorfind</link>
280 <link linkend="grep">grep</link>
283 <link linkend="findobj">findobj</link>
286 <link linkend="boolean">boolean</link>