1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
|
<?xml version="1.0" encoding="UTF-8"?>
<!--
* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
* Copyright (C) INRIA
*
* This file must be used under the terms of the CeCILL.
* This source file is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at
* http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
*
-->
<refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svg="http://www.w3.org/2000/svg" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" version="5.0-subset Scilab" xml:lang="en" xml:id="find">
<info>
<pubdate>$LastChangedDate$</pubdate>
</info>
<refnamediv>
<refname>find</refname>
<refpurpose> find indices of boolean vector or matrix true elements</refpurpose>
</refnamediv>
<refsynopsisdiv>
<title>Calling Sequence</title>
<synopsis>[ii]=find(x [,nmax])
[i1,i2,..]=find(x [,nmax])</synopsis>
</refsynopsisdiv>
<refsection>
<title>Parameters</title>
<variablelist>
<varlistentry>
<term>x</term>
<listitem>
<para>may be a boolean vector, a boolean matrix, a boolean
hypermatrix, a "standard" matrix or hypermatrix</para>
</listitem>
</varlistentry>
<varlistentry>
<term>nmax</term>
<listitem>
<para>an integer giving the maximum number of indices to return. The default value is -1 which stands for "all". This option can be used for efficiency, to avoid searching all indices.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>ii, i1, i2, .. </term>
<listitem>
<para>integer vectors of indices or empty matrices</para>
</listitem>
</varlistentry>
</variablelist>
</refsection>
<refsection>
<title>Description</title>
<para>
If <literal>x</literal> is a boolean matrix,</para>
<para><literal>ii=find(x)</literal> returns the vector
of indices <literal>i</literal> for which <literal>x(i)</literal> is "true". If no true element
found find returns an empty matrix.</para>
<para><literal>[i1,i2,..]=find(x)</literal> returns vectors of indices <literal>i1</literal> (for rows) and <literal>i2</literal> (for columns),..
such that <literal>x(i1(n),i2(n),..)</literal> is "true". If no true element
found find returns empty matrices in <literal>i1</literal>,
<literal>i2</literal>, ...</para>
<para>
if <literal>x</literal> is a standard matrix or hypermatrix <literal>find(x)</literal> is interpreted as
<literal>find(x<>0)</literal></para>
<para><literal>find([])</literal> returns <literal>[]</literal></para>
</refsection>
<refsection>
<title>Examples</title>
<programlisting role="example"><![CDATA[
beers=["Desperados", "Leffe", "Kronenbourg", "Heineken"];
find(beers=="Leffe") // OK
find(beers=="1664") // KO
find(beers=="Foster") // KO
beers=[beers, "Foster"]
find(beers=="Foster") // OK
A=rand(1,20);
w=find(A<0.4)
A(w)
w=find(A>100)
B=rand(1,20);
w=find(B<0.4,2) //at most 2 returned values
H=rand(4,3,5); //an hypermatrix
[i,j,k]=find(H>0.9)
H(i(1),j(1),k(1))
]]></programlisting>
</refsection>
<refsection>
<title>See Also</title>
<simplelist type="inline">
<member>
<link linkend="boolean">boolean</link>
</member>
<member>
<link linkend="extraction">extraction</link>
</member>
<member>
<link linkend="insertion">insertion</link>
</member>
<member>
<link linkend="vectorfind">vectorfind</link>
</member>
</simplelist>
</refsection>
</refentry>
|