1 <?xml version="1.0" encoding="UTF-8"?>
3 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
4 * Copyright (C) 2011 - Bernard DUJARDIN
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:mml="http://www.w3.org/1998/Math/MathML"
18 xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org"
19 xml:lang="fr" xml:id="find">
21 <refname>find</refname>
23 donne la position des éléments %T ou non nuls d'un tableau booléen ou numérique.
27 <title>Séquence d'appel</title>
35 <title>Paramètres</title>
41 Vecteur, matrice, ou hypermatrice de booléens ou de nombres.
42 Tout nombre non nul est équivalent à %T.
43 Les vecteurs ou matrices creuses sont acceptés.
51 un entier donnant le nombre maximal d'indices à retourner.
52 La valeur par défaut est -1 qui signifie "tous".
53 Cette option peut être utilisée dans un but d'efficacité
54 en évitant la recherche de tous les indices.
62 vecteur ligne des indices linéarisés des éléments %T ou non nuls,
68 <term>i1, i2, ..</term>
71 vecteurs ligne des indices directionels des élements %T ou non nuls,
79 <title>Description</title>
81 Si <literal>x</literal> est une matrice booléenne,
84 <literal>ii=find(x)</literal> retourne le vecteur des indices
85 <literal>i</literal> pour lesquels <literal>x(i)</literal> est "vrai".
86 Si aucun élément vrai n'est trouvé find retourne une matrice vide.
89 <literal>[i1,i2,..]=find(x)</literal> retourne le vecteur des indices
90 <literal>i1</literal> (pour les lignes) et <literal>i2</literal> (pour les colonnes),..
91 tel que <literal>x(i1(n),i2(n),..)</literal> est "vrai". Si aucun élément vrai n'est
92 trouvé find retourne des matrices vides dans <literal>i1</literal>,
93 <literal>i2</literal>, ...
96 Si <literal>x</literal> est une matrice standard ou une hypermatrice
97 <literal>find(x)</literal> est interprété comme
98 <literal>find(x<>0).</literal>
101 <literal>find([])</literal> retourne <literal>[].</literal>
105 <title>Exemples</title>
107 Avec un tableau booléen :
109 <programlisting role="example"><![CDATA[
110 A = [%F %T %T %F ; %T %F %F %T]
115 --> A = [%F %T %T %F ; %T %F %F %T]
129 Avec un tableau de nombres :
131 <programlisting role="example"><![CDATA[
132 B = [0 -1 0 3 ; 0 -1 -0.4 0]
138 --> B = [0 -1 0 3 ; 0 -1 -0.4 0]
147 --> [i, j] = find(B);
156 Avec une hypermatrice de nombres :
158 <programlisting role="example"><![CDATA[
159 E = grand(2,5,2,"uin",1,6)
163 --> E = grand(2,5,2,"uin",1,6)
177 Avec une matrice creuse numérique ou booléenne :
179 <programlisting role="example"><![CDATA[
188 // Avec une matrice creuse booléenne
197 3. 4. 5. 7. 9. 13. 14. 15. 18.
203 --> // Avec une matrice creuse booléenne
206 ( 3, 6) sparse boolean matrix
224 Avec le résultat booléen d'une condition individuelle sur du texte :
226 <programlisting role="example"><![CDATA[
227 beers = ["Desperados", "Leffe", "Kronenbourg", "Heineken"];
228 find(beers == "Leffe")
229 find(beers == "1664")
232 --> find(beers == "Leffe")
236 --> find(beers == "1664")
241 Adressage des éléments sélectionnés :
243 <programlisting role="example"><![CDATA[
244 // a) via leurs indices linéarisés :
245 H = [ 0 -2 -8 4 -5 -1
251 // b) Directement via le tableau de leur statut booléen :
256 --> // a) via leurs indices linéarisés :
257 --> H = [ 0 -2 -8 4 -5 -1
261 --> L(find(L<0)) = -10
263 0. -10. -10. 4. -10. -10.
264 -10. 2. -10. 5. 0. 1.
266 --> // b) Directement via le tableau de leur statut booléen :
270 0. -10. -10. 4. -10. -10.
271 -10. 2. -10. 5. 0. 1.
274 <refsection role="see also">
275 <title>Voir aussi</title>
276 <simplelist type="inline">
278 <link linkend="vectorfind">vectorfind</link>
281 <link linkend="grep">grep</link>
284 <link linkend="findobj">findobj</link>
287 <link linkend="boolean">boolean</link>