a9c07e0288b1ce9950e4b575198f914e1fdd5a3f
[scilab.git] / scilab / modules / graphics / help / en_US / 2d_plot / champ.xml
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!--
3  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
4  * Copyright (C) ENPC - Jean-Philippe Chancelier
5  *
6  * Copyright (C) 2012 - 2016 - Scilab Enterprises
7  *
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.
14  *
15  -->
16 <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" xmlns:scilab="http://www.scilab.org"  xml:lang="en" xml:id="champ">
17     <refnamediv>
18         <refname>champ</refname>
19         <refpurpose>2D vector field plot</refpurpose>
20     </refnamediv>
21     <refsynopsisdiv>
22         <title>Syntax</title>
23         <synopsis>
24             champ(x, y, fx, fy, [arfact, rect, strf])
25             champ(x, y, fx, fy, &lt;opt_args&gt;)
26         </synopsis>
27     </refsynopsisdiv>
28     <refsection>
29         <title>Arguments</title>
30         <variablelist>
31             <varlistentry>
32                 <term>x, y</term>
33                 <listitem>
34                     <para>two vectors which define the grid.</para>
35                 </listitem>
36             </varlistentry>
37             <varlistentry>
38                 <term>fx</term>
39                 <listitem>
40                     <para>
41                         a matrix which describes the x component of the vector
42                         field. <literal>fx(i,j)</literal> is the x
43                         component of the vector field at point
44                         <literal>(x(i),y(j))</literal>.
45                     </para>
46                 </listitem>
47             </varlistentry>
48             <varlistentry>
49                 <term>fy</term>
50                 <listitem>
51                     <para>
52                         a matrix which describes the y component of the vector
53                         field. <literal>fy(i,j)</literal> is the y component of
54                         the vector field at point <literal>(x(i),y(j))</literal>.
55                     </para>
56                 </listitem>
57             </varlistentry>
58             <varlistentry>
59                 <term>&lt;opt_args&gt;</term>
60                 <listitem>
61                     <para>
62                         This represents a sequence of statements
63                         <literal>key1=value1, key2=value2</literal>,... where
64                         <literal>key1</literal>, <literal>key2</literal>,... can
65                         be one of the following: <varname>arfact</varname>,
66                         <varname>rect</varname>, <varname>strf</varname> (see below).
67                     </para>
68                 </listitem>
69             </varlistentry>
70             <varlistentry>
71                 <term>arfact</term>
72                 <listitem>
73                     <para>
74                         an optional argument of type <literal>real</literal>
75                         which gives a scale factor for the display of the arrow
76                         heads on the plot (default value is
77                         <literal>1.0</literal>).
78                     </para>
79                 </listitem>
80             </varlistentry>
81             <varlistentry>
82                 <term>rect</term>
83                 <listitem>
84                     <para>
85                         a vector <literal>rect=[xmin, ymin, xmax, ymax]</literal>
86                         which gives the boundaries of the graphics frame to use.
87                     </para>
88                 </listitem>
89             </varlistentry>
90             <varlistentry>
91                 <term>strf</term>
92                 <listitem>
93                     <para>
94                         a string of length 3 "xyz" which has the same meaning as
95                         the <varname>strf</varname> parameter of
96                         <function>plot2d</function>. The first  character
97                         <literal>x</literal> has no effect with
98                         <function>champ</function>.
99                     </para>
100                 </listitem>
101             </varlistentry>
102         </variablelist>
103     </refsection>
104     <refsection>
105         <title>Description</title>
106         <para>
107             <function>champ</function> draws a 2D vector field. The length of
108             the arrows is proportional to the intensity of the field.
109         </para>
110         <para>
111             If you want colored arrows with the color of the arrows depending on
112             the intensity of the field, set <literal>gce().colored = "on"</literal>.
113         </para>
114         <para>
115             Enter the command <code>champ()</code> to see a demo.
116         </para>
117         <para>
118             Be cautioned about the fact that using <link linkend="meshgrid">meshgrid</link> function before
119             using <code>champ</code> requires adjustment. For more details, see the last example below.
120         </para>
121     </refsection>
122     <refsection>
123         <title>Examples</title>
124         <programlisting role="example"><![CDATA[
125 // using rect as plot boundaries
126 champ(-5:5,-5:5,rand(11,11),rand(11,11),rect=[-10,-10,10,10],arfact=2)
127  ]]></programlisting>
128         <scilab:image>
129             champ(-5:5,-5:5,rand(11,11),rand(11,11),rect=[-10,-10,10,10],arfact=2);
130         </scilab:image>
131         <programlisting role="example"><![CDATA[
132 // using (x,y) to get boundaries
133 clf()
134 champ(-5:5,-5:5,rand(11,11),rand(11,11),2,[-10,-10,10,10],"021")
135  ]]></programlisting>
136         <scilab:image>
137             champ(-5:5,-5:5,rand(11,11),rand(11,11),2,[-10,-10,10,10],"021")
138         </scilab:image>
139         <programlisting role="example"><![CDATA[
140 // using meshgrid to get fx and fy
141 clf()
142 x = linspace(-1,1,30);
143 y = linspace(-1,1,30);
144 [X,Y] = meshgrid(x,y);
145 fy = 2.*Y;
146 fx = 2.*X;
147 champ(x,y,fx',fy'); //here we have transposed fx and fy
148 ]]></programlisting>
149         <scilab:image>
150             x = linspace(-1,1,30);
151             y = linspace(-1,1,30);
152             [X,Y] = meshgrid(x,y);
153             fy = 2.*Y;
154             fx = 2.*X;
155             champ(x,y,fx',fy');
156         </scilab:image>
157     </refsection>
158     <refsection role="see also">
159         <title>See also</title>
160         <simplelist type="inline">
161             <member>
162                 <link linkend="fchamp">fchamp</link>
163             </member>
164             <member>
165                 <link linkend="xarrows">xarrows</link>
166             </member>
167             <member>
168                 <link linkend="polyline_properties">Arrowed polyline</link>
169             </member>
170         </simplelist>
171     </refsection>
172 </refentry>