13
13
<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:id="m2sci_any">
15
<refname>any (Matlab function)</refname>
16
<refpurpose>Test to determine if any nonzeros elements</refpurpose>
19
<title>Matlab/Scilab equivalent</title>
20
<informaltable border="1" width="100%">
23
<emphasis role="bold">Matlab</emphasis>
26
<emphasis role="bold">Scilab</emphasis>
31
<programlisting role="example"><![CDATA[
15
<refname>any (Matlab function)</refname>
16
<refpurpose>Test to determine if any nonzeros elements</refpurpose>
19
<title>Matlab/Scilab equivalent</title>
20
<informaltable border="1" width="100%">
23
<emphasis role="bold">Matlab</emphasis>
26
<emphasis role="bold">Scilab</emphasis>
31
<programlisting role="example"><![CDATA[
33
33
]]></programlisting>
36
<programlisting role="example"><![CDATA[
36
<programlisting role="example"><![CDATA[
38
38
]]></programlisting>
44
<title>Particular cases</title>
46
Matlab <emphasis role="bold">any</emphasis> function can work with complexes, what Scilab <emphasis role="bold">or</emphasis> can not, so a call to <emphasis role="bold">abs</emphasis> function can be necessary when translating from Matlab to Scilab.
50
<term>Matlab expression <emphasis role="bold">B=any(A)</emphasis> translated into Scilab by <emphasis role="bold">B=or(A)</emphasis>:</term>
53
If <emphasis role="bold">A</emphasis> is a matrix, <emphasis role="bold">any(A)</emphasis> is equivalent to <emphasis role="bold">any(A,1)</emphasis> in Matlab whereas in Scilab <emphasis role="bold">or(A)</emphasis> is a logical OR of all elements of <emphasis role="bold">A</emphasis>. If <emphasis role="bold">A</emphasis> is a multidimensional array then Matlab treats the values along the first non-singleton dimension, but Scilab returns logical OR of all elements of <emphasis role="bold">A</emphasis>.
58
<term>Matlab expression <emphasis role="bold">B=any(A,dim)</emphasis> translated into Scilab by <emphasis role="bold">B=or(A,dim)</emphasis>:</term>
61
In Scilab <emphasis role="bold">dim=1</emphasis> is equivalent to <emphasis role="bold">dim="r"</emphasis> and <emphasis role="bold">dim=2</emphasis> is equivalent to <emphasis role="bold">dim="c"</emphasis>. In Matlab, <emphasis role="bold">dim</emphasis> can be greater then the number of dimension of <emphasis role="bold">A</emphasis> (in this case, <emphasis role="bold">B=A</emphasis>), in Scilab you will get an error message.
68
<title>Examples</title>
69
<informaltable border="1" width="100%">
72
<emphasis role="bold">Matlab</emphasis>
75
<emphasis role="bold">Scilab</emphasis>
80
<programlisting role="example"><![CDATA[
44
<title>Particular cases</title>
46
Matlab <emphasis role="bold">any</emphasis> function can work with complexes, what Scilab <emphasis role="bold">or</emphasis> can not, so a call to <emphasis role="bold">abs</emphasis> function can be necessary when translating from Matlab to Scilab.
51
Matlab expression <emphasis role="bold">B=any(A)</emphasis> translated into Scilab by <emphasis role="bold">B=or(A)</emphasis>:
55
If <emphasis role="bold">A</emphasis> is a matrix, <emphasis role="bold">any(A)</emphasis> is equivalent to <emphasis role="bold">any(A,1)</emphasis> in Matlab whereas in Scilab <emphasis role="bold">or(A)</emphasis> is a logical OR of all elements of <emphasis role="bold">A</emphasis>. If <emphasis role="bold">A</emphasis> is a multidimensional array then Matlab treats the values along the first non-singleton dimension, but Scilab returns logical OR of all elements of <emphasis role="bold">A</emphasis>.
61
Matlab expression <emphasis role="bold">B=any(A,dim)</emphasis> translated into Scilab by <emphasis role="bold">B=or(A,dim)</emphasis>:
65
In Scilab <emphasis role="bold">dim=1</emphasis> is equivalent to <emphasis role="bold">dim="r"</emphasis> and <emphasis role="bold">dim=2</emphasis> is equivalent to <emphasis role="bold">dim="c"</emphasis>. In Matlab, <emphasis role="bold">dim</emphasis> can be greater then the number of dimension of <emphasis role="bold">A</emphasis> (in this case, <emphasis role="bold">B=A</emphasis>), in Scilab you will get an error message.
72
<title>Examples</title>
73
<informaltable border="1" width="100%">
76
<emphasis role="bold">Matlab</emphasis>
79
<emphasis role="bold">Scilab</emphasis>
84
<programlisting role="example"><![CDATA[
81
85
y = any([1,1,0;1,0,1])
83
87
y = any([1,1,0;1,0,1],1)
85
89
]]></programlisting>
88
<programlisting role="example"><![CDATA[
92
<programlisting role="example"><![CDATA[
89
93
y = or([1,1,0;1,0,1])
91
95
y = or([1,1,0;1,0,1],1)
93
97
]]></programlisting>