summaryrefslogtreecommitdiffstats
path: root/scilab_doc
diff options
context:
space:
mode:
authorFrancois Delebecque <Francois.Delebecque@inria.fr>2004-09-23 12:52:52 +0000
committerFrancois Delebecque <Francois.Delebecque@inria.fr>2004-09-23 12:52:52 +0000
commita0d9d653d9b36ed1c84402ea7d0a60dea9424622 (patch)
tree7d11cb4ea7f7bf1df7cf2f3f80a4df0e90350530 /scilab_doc
parent67a5b5327624c912a40eb96b0c3d4c00f7bf5957 (diff)
downloadscilab-a0d9d653d9b36ed1c84402ea7d0a60dea9424622.zip
scilab-a0d9d653d9b36ed1c84402ea7d0a60dea9424622.tar.gz
new
Diffstat (limited to 'scilab_doc')
-rwxr-xr-xscilab_doc/intro/chap1.tex252
-rwxr-xr-xscilab_doc/intro/chap2.tex525
-rwxr-xr-xscilab_doc/intro/chap3.tex36
-rwxr-xr-xscilab_doc/intro/chap4.tex88
-rwxr-xr-xscilab_doc/intro/chap5.tex1320
-rwxr-xr-xscilab_doc/intro/intro.tex25
6 files changed, 675 insertions, 1571 deletions
diff --git a/scilab_doc/intro/chap1.tex b/scilab_doc/intro/chap1.tex
index 9db88f1..a8d47d2 100755
--- a/scilab_doc/intro/chap1.tex
+++ b/scilab_doc/intro/chap1.tex
@@ -4,46 +4,48 @@
4 4
5\section{What is Scilab} 5\section{What is Scilab}
6 6
7Developed at INRIA, Scilab has been developed for system control and 7Developed at INRIA and ENPC, Scilab has been developed for engineering
8signal processing applications. It 8applications. It is freely distributed (see the copyright file) and the source
9is freely distributed in source code format (see the copyright file). 9code is available.
10 10
11Scilab is made of three distinct parts: an interpreter, 11Scilab is made of three distinct parts: an interpreter,
12libraries of functions (Scilab procedures) and libraries of Fortran 12a set of libraries of Fortran and C routines linked with Scilab
13and C routines. 13and a number of toolboxes written in Scilab language.
14These routines (which, strictly speaking, do not belong to Scilab but 14The numerical librairies (which, strictly speaking, do not belong to Scilab but
15are interactively called by the interpreter) are of 15are interactively called by the interpreter) are of
16independent interest and most of them are available through Netlib. 16independent interest and most of them are available through the Web.
17A few of them have been slightly modified for better compatibility
18with Scilab's interpreter.
19 17
20A key feature of the Scilab syntax is its ability to handle matrices: 18A key feature of the Scilab syntax is its ability to handle matrices:
21basic matrix manipulations such as concatenation, 19basic matrix manipulations such as concatenation,
22extraction or transpose are immediately performed as well as basic operations 20extraction or transpose are immediately performed as well as basic operations
23such as addition or multiplication. Scilab also aims at handling more complex 21such as addition or multiplication. The syntax for manipulating
24objects than numerical matrices. For instance, control people may want 22matrices is mostly compatible with Matlab.
25to manipulate rational or polynomial transfer matrices. This is 23Scilab also aims at handling more complex
26done in Scilab by manipulating lists and typed lists which allows a 24objects than numerical matrices. This is
25done in Scilab by manipulating structures which allows a
27natural symbolic representation of complicated 26natural symbolic representation of complicated
28mathematical objects such as transfer functions, linear systems or graphs 27objects such as transfer functions, linear systems or graphs
29(see Section~\ref{s2.5}). 28(see Section~\ref{s2.5}).
30 29
31 Polynomials, polynomials matrices and transfer matrices 30 Mathematical objects such as polynomials, polynomials matrices
32are also defined and the syntax used for manipulating these matrices 31and rational polynomial matrices are also defined and the syntax
33is identical to that used for manipulating constant vectors and matrices. 32used for manipulating these matrices is identical to that used for
33manipulating numerical vectors and matrices.
34 34
35 Scilab provides a variety of powerful primitives for 35 Scilab provides a variety of powerful primitives for
36the analysis of non-linear systems. 36the analysis of non-linear systems.
37Integration of explicit and implicit dynamic systems can be accomplished 37Integration of explicit and implicit dynamic systems can be accomplished
38numerically. The {\tt scicos} toolbox allows the graphic definition 38numerically. The {\tt scicos} toolbox allows the graphic definition
39and simulation of complex interconnected hybrid systems. 39and simulation of complex interconnected hybrid systems. Documentation
40about {\tt scicos} can be found at its the Web page
41\href{http://www.scicos.org}{scicos.org}.
40 42
41 There exist numerical optimization 43 There exist numerical optimization facilities for non linear
42facilities for non linear optimization (including 44optimization (including non differentiable optimization), quadratic
43non differentiable optimization), quadratic optimization and 45optimization and linear optimization (see also the contribution
44linear optimization. 46directory on the Scilab Web page).
45 47
46 Scilab has an open programming environment where the 48 Scilab has an open programming environment where the
47creation of functions and libraries of functions is completely in the 49creation of functions and libraries of functions is completely in the
48hands of the user (see Chapter~\ref{ch4}). 50hands of the user (see Chapter~\ref{ch4}).
49Functions are recognized as data objects in Scilab and, thus, can be 51Functions are recognized as data objects in Scilab and, thus, can be
@@ -68,11 +70,7 @@ a syntax which is natural and easy to use.
68 \item To provide a reasonable set of primitives which serve 70 \item To provide a reasonable set of primitives which serve
69 as a basis for a wide variety of calculations. 71 as a basis for a wide variety of calculations.
70 \item To have an open programming environment where new 72 \item To have an open programming environment where new
71 primitives are easily added. A useful tool distributed with 73 primitives are easily added.
72 Scilab is {\tt intersci} which
73is a tool for building interface programs to add new primitives
74i.e. to add new modules of Fortran or C code into Scilab.
75
76 \item To support library development through ``toolboxes'' of 74 \item To support library development through ``toolboxes'' of
77 functions devoted to specific 75 functions devoted to specific
78 applications (linear control, signal processing, 76 applications (linear control, signal processing,
@@ -80,7 +78,7 @@ i.e. to add new modules of Fortran or C code into Scilab.
80\end{itemize} 78\end{itemize}
81 79
82 The objective of this introduction manual is to give the user 80 The objective of this introduction manual is to give the user
83an idea of what Scilab can do. On line documentation on all 81an idea of what Scilab can do. On line documentation about all
84functions is available ({\tt help} command). 82functions is available ({\tt help} command).
85 83
86 84
@@ -90,11 +88,13 @@ Scilab is divided into a set of directories. The main directory
90\verb!SCIDIR! contains the following files: {\tt scilab.star} (startup file), the 88\verb!SCIDIR! contains the following files: {\tt scilab.star} (startup file), the
91copyright file {\tt notice.tex}, and the \verb!configure! files 89copyright file {\tt notice.tex}, and the \verb!configure! files
92(see(\ref{install})). 90(see(\ref{install})).
93The subdirectories are the following: 91The main subdirectories are the following:
94\begin{itemize} 92\begin{itemize}
95 93
96\item{{\tt bin} is the directory of the executable files. 94\item{{\tt bin} is the directory of the executable files.
97The starting script {\tt scilab} on Unix/Linux systems and {\tt runscilab.exe} on Windows95/NT, The executable code of Scilab: {\tt scilex} on Unix/Linux systems and {\tt scilex.exe} on Windows95/NT are there. 95The starting script {\tt scilab} on Unix/Linux systems and {\tt runscilab.exe} on Windows.
96The executable code of Scilab: {\tt scilex} on Unix/Linux systems and {\tt scilex.exe} on
97Windows are there.
98This directory also contains Shell scripts 98This directory also contains Shell scripts
99for managing or printing Postscript/\LaTeX\ files produced by Scilab.} 99for managing or printing Postscript/\LaTeX\ files produced by Scilab.}
100 100
@@ -108,29 +108,14 @@ Note that running a graphic function without input parameter
108provides an example of use for this function (for instance {\tt 108provides an example of use for this function (for instance {\tt
109plot2d()} displays an example for using {\tt plot2d} function). } 109plot2d()} displays an example for using {\tt plot2d} function). }
110 110
111\item{{\tt examples} contains useful examples of how to link 111\item{{\tt examples} contains examples of specific topics. It is shown
112external programs to scilab, using dynamic link or {\tt intersci}} 112in appropriate subdirectories how to add new C or Fortran program
113 113to Scilab (see \verb!addinter-tutorial!). More complex examples are given
114\item{{\tt doc} is the directory of the Scilab documentation: \LaTeX\ , dvi 114in \verb!addinter-examples!. The directory \verb!mex-examples!
115and Postscript files. 115contains examples of interfaces realized by emulating the Matlab
116This documentation is {\tt SCIDIR/doc/intro/intro.tex}. } 116mexfiles. The directory \verb!link-examples! illustrates the use of
117 117the \verb!call! function which allows to call external function within
118\item{{\tt geci} contains source code and binaries for GeCI which is an 118Scilab.}
119interactive communication manager created in order to
120manage remote executions of softwares and allow exchanges of messages
121beetwen those programs. It offers the possibility to exploit numerous
122machines on a network, as a virtual computer, by creating a
123distributed group of independent softwares
124(\verb!help communications! for a detailed description).
125GeCI is used for the link of Xmetanet with Scilab.}
126
127\item{\tt pvm3} contains source code and binaries of the PVM version
1283 which is another interactive communication manager.
129
130\item{{\tt imp} is the directory of the routines managing the Postscript files
131for print.}
132
133\item{{\tt libs} contains the Scilab libraries (compiled code).}
134 119
135\item{{\tt macros} contains the libraries of functions 120\item{{\tt macros} contains the libraries of functions
136which are available on-line. New libraries can easily be added 121which are available on-line. New libraries can easily be added
@@ -138,15 +123,12 @@ which are available on-line. New libraries can easily be added
138which contain ``Toolboxes'' for control, signal processing, etc... Strictly 123which contain ``Toolboxes'' for control, signal processing, etc... Strictly
139speaking Scilab is not organized in toolboxes : functions of a specific 124speaking Scilab is not organized in toolboxes : functions of a specific
140subdirectory can call functions of other directories; so, for example, the 125subdirectory can call functions of other directories; so, for example, the
141subdirectory {\tt signal} is not self-contained but its functions are all devoted 126subdirectory {\tt signal} is not self-contained but all the functions there
142to signal processing.} 127are devoted to signal processing.}
143 128
144\item{{\tt man} is the directory containing the manual divided 129\item{{\tt man} is the directory containing the manual divided
145into submanuals, corresponding to the on-line help and to 130into submanuals, corresponding to the on-line help.}
146a \LaTeX\ format of the reference manual. 131
147The \LaTeX\ code is produced by a
148translation of the Unix format Scilab manual (see the subdirectory
149{\tt SCIDIR/man}).}
150To get information about an item, one should enter 132To get information about an item, one should enter
151{\tt help item}\index{help@{\tt help}} 133{\tt help item}\index{help@{\tt help}}
152in Scilab or use the help window facility obtained with help button. 134in Scilab or use the help window facility obtained with help button.
@@ -154,77 +136,47 @@ To get information corresponding to a key-word, one should enter
154{\tt apropos key-word} or use 136{\tt apropos key-word} or use
155{\tt apropos}\index{apropos@{\tt apropos}} in the help window. 137{\tt apropos}\index{apropos@{\tt apropos}} in the help window.
156All the {\tt item}s and {\tt key-words} known by the {\tt help} and 138All the {\tt item}s and {\tt key-words} known by the {\tt help} and
157{\tt apropos} commands are in {\tt .cat} and {\tt whatis} files 139{\tt apropos} commands are in {\tt .html} and {\tt whatis} files
158located in the {\tt man} subdirectories. 140located in the {\tt man} subdirectories.
159 141
160To add new items to the {\verb!help!} and {\tt apropos} commands 142To add new items to the {\verb!help!} and {\tt apropos} commands
161the user can extend the list of directories available to the help 143the user can extend the list of directories available to the help
162browser by adapting the variable \verb!%helps!. 144browser by adapting the variable \verb!%helps!.
163See the README file in the \verb!man! directory and the example
164given in \verb!examples/man-examples! directory
165
166\item{{\tt maple} is the directory which contains the source code of Maple
167functions which allow the transfer of Maple objects
168into Scilab functions. For efficiency, the transfer
169is made through Fortran code generation which is dynamically linked
170to Scilab.}
171 145
172\item{{\tt routines} is a directory which contains the source code of all 146\item{{\tt routines} is a directory which contains the source code of all
173the numerical routines. The subdirectory {\tt default} is important 147the numerical routines. The subdirectory {\tt default} is important
174since it contains the 148since it contains the
175source code of routines which are necessary to customize Scilab.} 149source code of routines which are necessary to customize Scilab.
176In particular user's C or Fortran routines for ODE/DAE simulation 150In particular user's C or Fortran routines for ODE/DAE simulation
177or optimization can be included here (they can be also dynamically 151or optimization can be included here (they can be also dynamically
178linked). 152linked)}
179 153
180\item{{\tt examples} contains examples of specific topics. It is shown 154\item{{\tt tests} : this directory contains evaluation programs for testing
181in appropriate subdirectories how to add new C or Fortran program 155Scilab's installation on a machine. The file ``demos.tst'' tests all the
182to Scilab (see \verb!addinter-tutorial!). More complex examples are given 156demos.}
183in \verb!addinter-examples!. The directory \verb!mex-examples!
184contains examples of interfaces realized by emulating the Matlab
185mexfiles. The directory \verb!link-examples! illustrates the use of
186the \verb!call! function which allows to call external function within
187Scilab.}
188 157
189\item{{\tt intersci} contains a program which can be used to build 158\item{{\tt intersci} contains a program which can be used to build
190interface programs for adding new Fortran or C 159interface programs for adding new Fortran or C
191primitives to Scilab. This program is executed by the {\tt intersci} 160primitives to Scilab. This program is executed by the {\tt intersci}
192script in the {\tt bin/intersci} directory.} 161script in the {\tt bin/intersci} directory.}
193 162
194\item{{\tt scripts} is the directory which contains the source code of
195shell scripts files. Note that the list of printers \index{printers}
196names known by Scilab is defined there by an environment variable.}
197
198\item{{\tt tests} : this directory contains evaluation programs for testing
199Scilab's installation on a machine. The file ``demos.tst'' tests all the
200demos.}
201
202\item{{\tt wless, xless} is the Berkeley file browsing tool}
203
204\item{{\tt xmetanet} is the directory which contains {\tt xmetanet}, a
205graphic display for networks. Type {\tt metanet()} in Scilab to use it.}
206
207\end{itemize} 163\end{itemize}
208 164
209\section{Installing Scilab. System Requirements} 165\section{Installing Scilab. System Requirements}
210\label{install} 166\label{install}
211Scilab is distributed in source code format; binaries for Windows95/NT 167Scilab is distributed in source code format; binaries for Windows98/NT/XP
212systems and several popular Unix/Linux-XWindow systems are also 168systems and several popular Unix/Linux-XWindow systems are also
213available: Dec Alpha (OSF V4), Dec Mips (ULTRIX 4.2), Sun Sparc 169available. See the Scilab Web page and the contributions for specific
214stations (Sun OS), Sun Sparc stations (Sun Solaris), HP9000 (HP-UX 170ports. All of these binaries versions include tk/tcl interface.
215V10), SGI Mips Irix, PC Linux. All of these binaries versions include
216tk/tcl interface.
217 171
218The installation requirements are the following : 172The installation requirements are the following :
219 173
220- for the source version: Scilab requires approximately 130Mb of disk 174- for the source version: Scilab requires approximately 130Mb of disk
221storage to unpack and install (all sources included). You need X 175storage to unpack and install (all sources included). You a C
222Window (X11R4, X11R5 or X11R6, C compiler and Fortran compiler 176compiler and a Fortran compiler.
223(e.g. f2c or g77 or Visual C++ for Windows systems).
224 177
225- for the binary version: the minimum for running Scilab (without 178- for the binary version: the minimum for running Scilab (without
226sources) is about 40 Mb when decompressed. 179sources) is about 40 Mb when decompressed.
227These versions are partially statically linked and in principle do not require a fortran compiler.
228 180
229\label{stks} 181\label{stks}
230Scilab uses a large internal stack for its calculations. This size 182Scilab uses a large internal stack for its calculations. This size
@@ -234,7 +186,7 @@ command. The default dimension of the internal stack can be adapted
234by modifying the variable {\tt newstacksize} in the {\tt scilab.star} 186by modifying the variable {\tt newstacksize} in the {\tt scilab.star}
235script. 187script.
236 188
237- For more information on the installation, please look at the README files 189- For more information on the installation, please look at the README files.
238 190
239\section{Documentation} 191\section{Documentation}
240 192
@@ -244,21 +196,16 @@ reports devoted to specific toolboxes: Scicos (graphic system builder
244and simulator), Signal (Signal processing toolbox), Lmitool (interface for 196and simulator), Signal (Signal processing toolbox), Lmitool (interface for
245LMI problems), Metanet (graph and network toolbox). An FAQ is 197LMI problems), Metanet (graph and network toolbox). An FAQ is
246available at Scilab home page:\\ 198available at Scilab home page:\\
247(\verb!http://www-rocq.inria.fr/scilab!)\index{home page}. 199(\verb!http://www.scilab.org!)\index{home page}.
200
201Several documents are available in French, German, Spanish, Chinese etc.
202See the Scilab Web page.
248 203
249\section{Scilab at a Glance. A Tutorial} 204\section{Scilab at a Glance. A Tutorial}
250 205
251\subsection{Getting Started} 206\subsection{Getting Started}
252 207
253Scilab is called by running the {\tt scilab} script in the 208After starting Scilab, you get:
254directory {\tt SCIDIR/bin} ({\tt SCIDIR} denotes the directory
255where Scilab is installed).
256This shell script runs Scilab in an Xwindow environment (this
257script file can be invoked with
258specific parameters such as \verb!-nw! for ``no-window'').
259You will immediatly get the Scilab window with the following banner and
260prompt represented by the {\tt -->} :
261
262 209
263\bigskip 210\bigskip
264 211
@@ -268,8 +215,8 @@ prompt represented by the {\tt -->} :
268 =========== 215 ===========
269 216
270 217
271 Scilab-2.x ( 12 July 1998 ) 218 Scilab-x.y.z
272 Copyright (C) 1989-98 INRIA 219 Copyright (C) 1989-xx INRIA/ENPC
273 220
274 221
275Startup execution: 222Startup execution:
@@ -332,65 +279,6 @@ useful if you type your commands in an editor. Another way to
332``load'' files containing Scilab statements 279``load'' files containing Scilab statements
333is available with the {\tt File/File Operations} button. 280is available with the {\tt File/File Operations} button.
334 281
335\subsection{Buttons}
336The Scilab window has the following {\bf Control} buttons.\\
337
338%
339\begin{itemize}
340\item Stop interrupts execution of Scilab and enters in
341{\tt pause} mode
342\item Resume continues execution after a {\tt pause}
343entered as a command in a function or generated by the {\tt Stop}
344button or Control C.
345\item Abort aborts execution after one (or several) {\tt pause},
346and returns to top-level prompt
347\item Restart clears all variables and executes startup files
348\item Quit quits Scilab
349\item Kill kills Scilab shell script
350\item Demos for interactive run of some demos
351\item File Operations facility for loading functions or data into
352Scilab, or executing script files.
353\item Help : invokes on-line help with the tree of the man and the
354names of the corresponding items. It is possible to type directly
355{\tt help <item>} in the Scilab window.
356\item Graphic Window : select active graphic window
357\end{itemize}
358%
359New buttons can be added by the
360{\tt addmenu}\index{addmenu@{\tt addmenu}} command.
361Note that the command:\\
362{\tt SCIDIR/bin/scilab -nw} \\
363invokes Scilab in the ``no-window'' mode.
364
365\subsection{Customizing your Scilab - Unix only}
366
367
368The parameters of the different windows opened by
369Scilab can be easily changed. The way for doing that is to edit the files
370contained in the directory {\tt X11-defaults}. The first possibility is
371to directly customize these files. Another way is to copy
372the right lines with the modifications in the {\tt .Xdefaults}
373file of the home directory.
374These modifications are activated by starting again Xwindow or with the
375command {\tt xrdb .Xdefaults}. Scilab will read the {\tt .Xdefaults} file:
376the lines of this
377file will cancel and replace the corresponding lines of X11-defaults.
378
379A simple example :
380
381\begin{verbatim}
382Xscilab.color*Scrollbar.background:red
383Xscilab*vpane.height: 500
384Xscilab*vpane.width: 500
385\end{verbatim}
386
387in {\tt .Xdefaults} will change the 500x650 window to a square window of
388500x500 and the
389scrollbar background color changes from green to red.
390
391An important parameter for customizing Scilab is \verb!stacksize!
392discussed in \ref{install}.
393
394\subsection{Sample Session for Beginners} 282\subsection{Sample Session for Beginners}
395 283
396We present now some simple commands. At the carriage return all the 284We present now some simple commands. At the carriage return all the
@@ -446,10 +334,16 @@ A more complicated command which creates a polynomial.
446 334
447\noindent\dotfill 335\noindent\dotfill
448 336
337\input{diary/d1p41.dia}
338
339Definition of a structure variable.
340
341\noindent\dotfill
342
449\input{diary/d1p5.dia} 343\input{diary/d1p5.dia}
450 344
451Definition of a polynomial matrix. The syntax for polynomial matrices 345Definition of a polynomial matrix. The syntax for polynomial matrices
452is the same as for constant matrices. Calculation of the 346is the same as for numerical matrices. Calculation of the
453determinant of the polynomial matrix by the {\tt det} function. 347determinant of the polynomial matrix by the {\tt det} function.
454 348
455 349
@@ -562,16 +456,18 @@ by {\tt exec} or by {\tt getf} ).
562 456
563\input{diary/d1p15.dia} 457\input{diary/d1p15.dia}
564 458
565Relation with the Unix environment. 459Relation with the host environment.
566 460
567\noindent\dotfill 461\noindent\dotfill
568 462
569\input{diary/d1p16.dia} 463\input{diary/d1p16.dia}
570 464
571Definition of a column vector of character strings used for defining a C 465Definition of a column vector of character strings used for defining a C
572function file. The routine is compiled (needs a compiler), dynamically 466function file. The routine is compiled (needs a compiler),
467and a shared library is done. The libary is dynamically
573linked to Scilab by the {\tt link} command, and interactively called 468linked to Scilab by the {\tt link} command, and interactively called
574by the function {\tt myplus}. 469by the function {\tt myplus}. {\tt myplus} passes variables from Scilab
470to C and conversely.
575 471
576\noindent\dotfill 472\noindent\dotfill
577 473
diff --git a/scilab_doc/intro/chap2.tex b/scilab_doc/intro/chap2.tex
index 49e12d2..abaaa8e 100755
--- a/scilab_doc/intro/chap2.tex
+++ b/scilab_doc/intro/chap2.tex
@@ -3,13 +3,11 @@
3\chapter{Data Types} 3\chapter{Data Types}
4\label{ch2} 4\label{ch2}
5\index{data types} 5\index{data types}
6
7Scilab recognizes several data types. 6Scilab recognizes several data types.
8 Scalar objects are constants, booleans, polynomials, strings and 7 Scalar objects are numerical constants, booleans, polynomials, strings and
9rationals (quotients of polynomials). These objects in turn allow to 8rationals (quotients of polynomials). These objects in turn allow to
10define matrices which admit these scalars as entries. 9define matrices which admit these scalars as entries.
11Other basic objects are lists, typed-lists and functions. Only 10Other basic objects are lists, typed-lists and functions.
12constant and boolean sparse matrices are defined.
13% 11%
14The objective of this chapter is to describe the use of each of 12The objective of this chapter is to describe the use of each of
15these data types. 13these data types.
@@ -55,7 +53,7 @@ of these objects are revealed in the following Scilab sessions.
55Scalars are either real or complex numbers. The values of 53Scalars are either real or complex numbers. The values of
56scalars can be assigned to variable names chosen by the user. 54scalars can be assigned to variable names chosen by the user.
57\begin{verbatim} 55\begin{verbatim}
58--> a=5+2*%i 56--> a=5+2*%i //a complex number
59 a = 57 a =
60 58
61 5. + 2.i 59 5. + 2.i
@@ -317,10 +315,10 @@ manipulated as full matrices.
317\index{data types!character strings} 315\index{data types!character strings}
318\index{character strings} 316\index{character strings}
319 317
320 Character strings can be created by using single or double quotes. 318Character strings can be created by using single or double quotes.
321Concatenation of strings is performed by the {\tt +} operation. 319Concatenation of strings is performed by the {\tt +} operation.
322Matrices of character strings are constructed as ordinary matrices, 320Matrices of character strings are constructed as ordinary matrices,
323e.g. using brackets. A very important feature of matrices of 321e.g. using brackets. An important feature of matrices of
324character strings is the capacity to manipulate and create functions. 322character strings is the capacity to manipulate and create functions.
325Furthermore, symbolic manipulation of mathematical objects can be 323Furthermore, symbolic manipulation of mathematical objects can be
326implemented using matrices of character strings. The following 324implemented using matrices of character strings. The following
@@ -354,10 +352,46 @@ Note that in the above Scilab session the function
354{\tt trianfml}\index{trianfml@{\tt trianfml}}\index{symbolic triangularization} 352{\tt trianfml}\index{trianfml@{\tt trianfml}}\index{symbolic triangularization}
355performs the symbolic triangularization of the matrix {\tt A}. 353performs the symbolic triangularization of the matrix {\tt A}.
356The value of the resulting symbolic matrix can be obtained by 354The value of the resulting symbolic matrix can be obtained by
357using {\tt evstr}. 355using {\tt evstr}.
356
357The following table gives the list of some useful functions:
358
359\begin{center}
360\begin{tabular}{|c|c|}
361\hline
362\verb!ascii! & ascii code of strings\\ \hline
363
364\verb!execstr! & executes the string\\ \hline
365
366\verb!grep ! & looks for a chain into a matrix \\ \hline
367
368\verb!sort, gsort ! & sorting (lexicographic,...) \\ \hline
369
370\verb!part! & extract a subchain \\ \hline
371
372\verb!mmscanf! & formated read into a chain \\ \hline
373
374\verb!msprintf! & construct a chain/vector \\ \hline
375
376\verb!strindex! & location of a subchain \\ \hline
377
378\verb!string ! & convert into a string \\ \hline
379
380\verb!stripblanks! & remove blank characters \\ \hline
358 381
359 A very important aspect of character strings is that they 382\verb!strsubst! & chain replacement \\ \hline
360can be used to automatically create new functions (for more on functions 383
384\verb!tokens! & cuts a chain \\ \hline
385
386\verb!strcat! & catenates chains \\ \hline
387
388\verb!length! & chain length \\ \hline
389\end{tabular}
390\end{center}
391
392
393 A string matrices can be used to create new
394functions (for more on functions
361see Section~\ref{s4.2}). An example of automatically creating a 395see Section~\ref{s4.2}). An example of automatically creating a
362function is illustrated in the following Scilab session where it is 396function is illustrated in the following Scilab session where it is
363desired to study a polynomial of two variables {\tt s} and {\tt t}. 397desired to study a polynomial of two variables {\tt s} and {\tt t}.
@@ -366,13 +400,12 @@ supported in Scilab, we can construct a new data structure using
366a list (see Section~\ref{s2.5}). 400a list (see Section~\ref{s2.5}).
367The polynomial to be studied is $(t^2+2t^3)-(t+t^2)s+ts^2+s^3$. 401The polynomial to be studied is $(t^2+2t^3)-(t+t^2)s+ts^2+s^3$.
368\begin{verbatim} 402\begin{verbatim}
369-->getf("macros/make_macro.sci");
370
371-->s=poly(0,'s');t=poly(0,'t'); 403-->s=poly(0,'s');t=poly(0,'t');
372 404
373-->p=list(t^2+2*t^3,-t-t^2,t,1+0*t); 405-->p=list(t^2+2*t^3,-t-t^2,t,1+0*t);
374 406
375-->pst=makefunction(p) //pst is a function t->p (number->polynomial) 407-->pst=makefunction(p) //pst is a function
408// t->p (number->polynomial)
376 pst = 409 pst =
377 410
378[p]=pst(t) 411[p]=pst(t)
@@ -414,7 +447,7 @@ evaluates to the polynomial in two variables.
414 447
415 Polynomials are easily created and manipulated in Scilab. 448 Polynomials are easily created and manipulated in Scilab.
416Manipulation of polynomial matrices is essentially identical 449Manipulation of polynomial matrices is essentially identical
417to that of constant matrices. 450to that of constant numerical matrices.
418The {\tt poly}\index{poly@{\tt poly}} 451The {\tt poly}\index{poly@{\tt poly}}
419primitive in Scilab can be used to specify the coefficients 452primitive in Scilab can be used to specify the coefficients
420of a polynomial or the roots of a polynomial. 453of a polynomial or the roots of a polynomial.
@@ -476,13 +509,7 @@ for systems theory.
476 509
477-->s=poly(0,'s'); 510-->s=poly(0,'s');
478 511
479-->A=[1 s;s 1+s^2] 512-->A=[1 s;s 1+s^2]; //Polynomial matrix
480 A =
481
482! 1 s !
483! !
484! 2 !
485! s 1 + s !
486 513
487--> B=[1/s 1/(1+s);1/(1+s) 1/s^2] 514--> B=[1/s 1/(1+s);1/(1+s) 1/s^2]
488 B = 515 B =
@@ -691,6 +718,89 @@ AND, OR and NOT bit-wise operations.
691 253 718 253
692\end{verbatim} 719\end{verbatim}
693%%%%% 720%%%%%
721\section{N-dimensionnal arrays}
722N-dimensionnal array can be defined and handled in simple way:
723\begin{verbatim}
724-->M(2,2,2)=3
725 M =
726
727(:,:,1)
728
729! 0. 0. !
730! 0. 0. !
731(:,:,2)
732
733! 0. 0. !
734! 0. 3. !
735
736-->M(:,:,1)=rand(2,2)
737 M =
738
739(:,:,1)
740
741! 0.9329616 0.312642 !
742! 0.2146008 0.3616361 !
743(:,:,2)
744
745! 0. 0. !
746! 0. 3. !
747
748-->M(2,2,:)
749 ans =
750
751(:,:,1)
752
753 0.3616361
754(:,:,2)
755
756 3.
757-->size(M)
758 ans =
759
760! 2. 2. 2. !
761
762-->size(M,3)
763 ans =
764
765 2.
766
767\end{verbatim}
768
769They can be created from a vector of data and a vector of dimension
770
771\begin{verbatim}
772-->hypermat([2 3,2],1:12)
773 ans =
774
775(:,:,1)
776
777! 1. 3. 5. !
778! 2. 4. 6. !
779(:,:,2)
780
781! 7. 9. 11. !
782! 8. 10. 12. !
783
784\end{verbatim}
785
786N-dimensionnal matrices are coded as {\tt mlists} with 2 fields~:
787\begin{verbatim}
788-->M=hypermat([2,3,2],1:12);
789-->M.dims
790 ans =
791
792! 2. 3. 2. !
793-->M.entries'
794ans =
795 column 1 to 11
796
797! 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. !
798
799 column 12
800
801! 12. !
802\end{verbatim}
803
694 804
695\section{Lists} 805\section{Lists}
696\label{s2.5} 806\label{s2.5}
@@ -709,26 +819,16 @@ example:
709\begin{verbatim} 819\begin{verbatim}
710-->L=list(1,'w',ones(2,2)) //L is a list made of 3 entries 820-->L=list(1,'w',ones(2,2)) //L is a list made of 3 entries
711 L = 821 L =
712
713
714 L(1) 822 L(1)
715 823
716 1. 824 1.
717
718 L(2) 825 L(2)
719
720 w 826 w
721
722 L(3) 827 L(3)
723 828 ! 1. 1. !
724! 1. 1. !
725! 1. 1. ! 829! 1. 1. !
726 830
727-->L(3) //extracting entry 3 of list L 831-->L(3); //extracting entry 3 of list L
728 ans =
729
730! 1. 1. !
731! 1. 1. !
732 832
733-->L(3)(2,2) //entry 2,2 of matrix L(3) 833-->L(3)(2,2) //entry 2,2 of matrix L(3)
734 ans = 834 ans =
@@ -737,26 +837,16 @@ example:
737 837
738-->L(2)=list('w',rand(2,2)) //nested list: L(2) is now a list 838-->L(2)=list('w',rand(2,2)) //nested list: L(2) is now a list
739 L = 839 L =
740
741
742 L(1) 840 L(1)
743 841
744 1. 842 1.
745
746 L(2) 843 L(2)
747
748
749 L(2)(1) 844 L(2)(1)
750
751 w 845 w
752
753 L(2)(2) 846 L(2)(2)
754
755! 0.6653811 0.8497452 ! 847! 0.6653811 0.8497452 !
756! 0.6283918 0.6857310 ! 848! 0.6283918 0.6857310 !
757
758 L(3) 849 L(3)
759
760! 1. 1. ! 850! 1. 1. !
761! 1. 1. ! 851! 1. 1. !
762 852
@@ -778,10 +868,7 @@ by using character strings (the names) as shown below.
778\begin{verbatim} 868\begin{verbatim}
779-->L=tlist(['Car';'Name';'Dimensions'],'Nevada',[2,3]) 869-->L=tlist(['Car';'Name';'Dimensions'],'Nevada',[2,3])
780 L = 870 L =
781
782
783 L(1) 871 L(1)
784
785!Car ! 872!Car !
786! ! 873! !
787!Name ! 874!Name !
@@ -789,23 +876,16 @@ by using character strings (the names) as shown below.
789!Dimensions ! 876!Dimensions !
790 877
791 L(2) 878 L(2)
792
793 Nevada 879 Nevada
794
795 L(3) 880 L(3)
796
797! 2. 3. ! 881! 2. 3. !
798 882
799-->L.Name //same as L(2) 883-->L.Name //same as L(2)
800 ans = 884 ans =
801
802 Nevada 885 Nevada
803
804-->L.Dimensions(1,2)=2.3 886-->L.Dimensions(1,2)=2.3
805 887
806 L = 888 L =
807
808
809 L(1) 889 L(1)
810 890
811!Car ! 891!Car !
@@ -815,13 +895,10 @@ by using character strings (the names) as shown below.
815!Dimensions ! 895!Dimensions !
816 896
817 L(2) 897 L(2)
818
819 Nevada 898 Nevada
820
821 L(3) 899 L(3)
822 900
823! 2. 2.3 ! 901! 2. 2.3 !
824
825 902
826-->L(3)(1,2) 903-->L(3)(1,2)
827 ans = 904 ans =
@@ -836,264 +913,10 @@ by using character strings (the names) as shown below.
836An important feature of typed-lists is that it is possible to define 913An important feature of typed-lists is that it is possible to define
837operators acting on them (overloading), i.e., it is possible 914operators acting on them (overloading), i.e., it is possible
838to define e.g. the multiplication \verb!L1*L2! of the two typed lists 915to define e.g. the multiplication \verb!L1*L2! of the two typed lists
839\verb!L1! and \verb!L2!. An example of use is given below, where 916\verb!L1! and \verb!L2!.
840linear systems manipulations (concatenation, addition,
841multiplication,...) are done by such operations.
842\section{N-dimensionnal arrays}
843N-dimensionnal array can be defined and handled in simple way:
844\begin{verbatim}
845-->M(2,2,2)=3
846 M =
847
848(:,:,1)
849
850! 0. 0. !
851! 0. 0. !
852(:,:,2)
853
854! 0. 0. !
855! 0. 3. !
856
857-->M(:,:,1)=rand(2,2)
858 M =
859
860(:,:,1)
861
862! 0.9329616 0.312642 !
863! 0.2146008 0.3616361 !
864(:,:,2)
865
866! 0. 0. !
867! 0. 3. !
868
869-->M(2,2,:)
870 ans =
871
872(:,:,1)
873
874 0.3616361
875(:,:,2)
876
877 3.
878-->size(M)
879 ans =
880
881! 2. 2. 2. !
882
883-->size(M,3)
884 ans =
885
886 2.
887
888\end{verbatim}
889 917
890They can be created from a vector of data and a vector of dimension
891
892\begin{verbatim}
893-->hypermat([2 3,2],1:12)
894 ans =
895
896(:,:,1)
897
898! 1. 3. 5. !
899! 2. 4. 6. !
900(:,:,2)
901
902! 7. 9. 11. !
903! 8. 10. 12. !
904
905\end{verbatim}
906 918
907N-dimensionnal matrices are coded as {\tt mlists} with 2 fields~: 919\section{Functions}
908\begin{verbatim}
909-->M=hypermat([2 3,2],1:12);
910-->M.dims
911 ans =
912
913! 2. 3. 2. !
914-->M.entries
915 ans =
916
917! 1. !
918! 2. !
919! 3. !
920! 4. !
921! 5. !
922! 6. !
923! 7. !
924! 8. !
925! 9. !
926! 10. !
927! 11. !
928! 12. !
929\end{verbatim}
930
931\section{Linear system representation}
932Linear systems are treated as specific typed lists {\tt tlist}.
933The basic function which is used for defining linear systems is {\tt syslin}.
934This function receives as parameters the constant matrices which
935define a linear system in state-space form or, in the case of
936system in transfer form, its input must be a rational matrix.
937To be more specific, the calling sequence of {\tt syslin} is
938either {\tt Sl=syslin('dom',A,B,C,D,x0)} or {\tt Sl=syslin('dom',trmat)}.
939{\tt dom} is one of the character strings {\tt 'c'} or {\tt 'd'}
940for continuous time or discrete time systems respectively.
941It is useful to note that {\tt D} can be a polynomial matrix
942(improper systems); {\tt D} and {\tt x0} are optional arguments.
943{\tt trmat} is a rational matrix i.e. it is defined as a matrix
944of rationals (ratios of polynomials). {\tt syslin} just converts
945its arguments (e.g. the four matrices A,B,C,D) into a typed
946list {\tt Sl}. For state space representation {\tt Sl} is
947the {\tt tlist(['lss','A','B','C','D'],A,B,C,D,'dom')}. This tlist
948representation allows to access the A-matrix i.e. the second entry of
949{\tt Sl} by the syntax {\tt Sl('A')} (equivalent to {\tt Sl(2)}).
950Conversion from a representation to another is done by {\tt ss2tf}
951or {\tt tf2ss}. Improper systems are also treated. {\tt syslin}
952defines linear systems as specific {\tt tlist}. ({\tt help syslin}).
953
954\input{diary/syslin.dia}
955
956 The list representation allows manipulating linear systems as
957abstract data objects. For example, the linear system can be combined
958with other linear systems or the transfer function representation of
959the linear system can be obtained as was done above using {\tt ss2tf}.
960Note that the transfer function representation of the linear system
961is itself a tlist.
962 A very useful aspect of the manipulation of systems
963is that a system can be handled as a data object.
964Linear systems can be
965inter-connected\index{linear systems!inter-connection of},
966their representation
967can easily be changed from state-space to transfer function
968and vice versa.
969
970 The inter-connection of linear systems can be made
971as illustrated in Figure~\ref{f3.2}.
972%
973\begin{figure}
974
975%BEGIN IMAGE
976\begin{center}
977\begin{picture}(200,330)(0,-60)
978
979\put(180,280){\makebox(0,0)[lb]{\tt S2*S1}}
980\put(9,280){\circle{2}}
981\put(10,280){\vector(1,0){20}}
982\put(30,270){\framebox(30,20){$S_1$}}
983\put(60,280){\vector(1,0){30}}
984\put(90,270){\framebox(30,20){$S_2$}}
985\put(120,280){\vector(1,0){20}}
986\put(141,280){\circle{2}}
987
988\put(180,220){\makebox(0,0)[lb]{\tt S1+S2}}
989\put(29,220){\circle{2}}
990\put(30,220){\line(1,0){20}}
991\put(50,220){\circle*{2}}
992\put(50,200){\line(0,1){40}}
993\put(50,200){\vector(1,0){20}}
994\put(50,240){\vector(1,0){20}}
995\put(70,190){\framebox(30,20){$S_2$}}
996\put(70,230){\framebox(30,20){$S_1$}}
997\put(100,200){\line(1,0){20}}
998\put(100,240){\line(1,0){20}}
999\put(120,240){\vector(0,-1){15}}
1000\put(120,200){\vector(0,1){15}}
1001\put(120,220){\circle{10}}
1002\put(120,220){\framebox(0,0){$+$}}
1003\put(125,220){\vector(1,0){15}}
1004\put(141,220){\circle{2}}
1005
1006\put(180,140){\makebox(0,0)[lb]{\tt [S1,S2]}}
1007\put(49,160){\circle{2}}
1008\put(49,120){\circle{2}}
1009\put(50,120){\vector(1,0){20}}
1010\put(50,160){\vector(1,0){20}}
1011\put(70,110){\framebox(30,20){$S_2$}}
1012\put(70,150){\framebox(30,20){$S_1$}}
1013\put(100,120){\line(1,0){20}}
1014\put(100,160){\line(1,0){20}}
1015\put(120,160){\vector(0,-1){15}}
1016\put(120,120){\vector(0,1){15}}
1017\put(120,140){\circle{10}}
1018\put(120,140){\framebox(0,0){$+$}}
1019\put(125,140){\vector(1,0){15}}
1020\put(141,140){\circle{2}}
1021
1022\put(180,50){\makebox(0,0)[lb]{\tt [S1 ; S2]}}
1023\put(49,50){\circle{2}}
1024\put(50,50){\line(1,0){20}}
1025\put(70,50){\circle*{2}}
1026\put(70,30){\line(0,1){40}}
1027\put(70,30){\vector(1,0){20}}
1028\put(70,70){\vector(1,0){20}}
1029\put(90,20){\framebox(30,20){$S_2$}}
1030\put(90,60){\framebox(30,20){$S_1$}}
1031\put(120,30){\vector(1,0){20}}
1032\put(120,70){\vector(1,0){20}}
1033\put(141,30){\circle{2}}
1034\put(141,70){\circle{2}}
1035
1036\put(180,-40){\makebox(0,0)[lb]{\tt S1/.S2}}
1037\put(70,-20){\circle{10}}
1038\put(70,-20){\framebox(0,0){$+$}}
1039\put(34,-20){\vector(1,0){30}}
1040\put(33,-20){\circle{2}}
1041\put(70,-60){\line(0,1){40}}
1042\put(70,-60){\line(1,0){20}}
1043\put(70,-20){\vector(1,0){20}}
1044\put(90,-70){\framebox(30,20){$S_2$}}
1045\put(90,-30){\framebox(30,20){$S_1$}}
1046\put(140,-60){\vector(-1,0){20}}
1047\put(120,-20){\line(1,0){20}}
1048\put(141,-20){\circle{2}}
1049\put(140,-60){\line(0,1){40}}
1050\end{picture}
1051\end{center}
1052%END IMAGE
1053%HEVEA\imageflush
1054
1055\caption{Inter-Connection of Linear Systems}
1056\label{f3.2}
1057\end{figure}
1058%
1059For each of the possible inter-connections of two systems
1060{\tt S1} and {\tt S2} the command which makes the inter-connection
1061is shown on the right side of the corresponding block diagram in
1062Figure~\ref{f3.2}. Note that feedback interconnection is performed by
1063\verb!S1/.S2!.
1064
1065 The representation of linear systems can be in state-space
1066form or in transfer function form. These two representations can
1067be interchanged by using the functions
1068{\tt tf2ss}\index{linear systems!{\tt tf2ss}}\index{tf2ss@{\tt tf2ss}} and
1069{\tt ss2tf}\index{linear systems!{\tt ss2tf}}\index{ss2tf@{\tt ss2tf}}
1070which change the representations of systems from transfer function
1071to state-space and from state-space to transfer function, respectively.
1072An example of the creation, the change in representation, and the
1073inter-connection of linear systems is demonstrated in the following
1074Scilab session.
1075
1076\input{diary/connect.dia}
1077
1078The above session is a bit long but illustrates some very important
1079aspects of the handling of linear systems. First, two linear systems
1080are created in transfer function form using the function called
1081{\tt syslin}\index{linear systems!{\tt syslin}}\index{syslin@{\tt syslin}}.
1082This function was used to label the systems in this example
1083as being continuous (as opposed to discrete).
1084The primitive {\tt tf2ss} is used to convert one of the
1085two transfer functions to its equivalent state-space representation
1086which is in list form (note that the function {\tt ssprint} creates a more
1087readable format for the state-space linear system).
1088The following multiplication of the two systems yields their
1089series inter-connection. Notice that the inter-connection
1090of the two systems is effected even though one of the systems is
1091in state-space form and the other is in transfer function form.
1092The resulting inter-connection is given in state-space form.
1093Finally, the function {\tt ss2tf} is used to convert the resulting
1094inter-connected systems to the equivalent transfer function representation.
1095
1096\section{Functions (Macros)}
1097\label{s2.6} 920\label{s2.6}
1098\index{data types!functions} 921\index{data types!functions}
1099\index{functions} 922\index{functions}
@@ -1115,8 +938,6 @@ can be created directly in the Scilab environment using the syntax
1115--> if y>0 then, x=1; else, x=-1; end 938--> if y>0 then, x=1; else, x=-1; end
1116--> endfunction 939--> endfunction
1117 940
1118--> deff('[x]=foo(y)','if y>0 then, x=1; else, x=-1; end')
1119
1120--> foo(5) 941--> foo(5)
1121 ans = 942 ans =
1122 943
@@ -1202,7 +1023,9 @@ SYMBOL & OPERATION
1202 1023
1203\verb!( )! & insertion: \verb!a(k)=m! \\ \hline 1024\verb!( )! & insertion: \verb!a(k)=m! \\ \hline
1204 1025
1205\verb!'! & transpose \\ \hline 1026\verb!.'! & transpose \\ \hline
1027
1028\verb!'! & conjugate transpose \\ \hline
1206 1029
1207\verb!+! & addition \\ \hline 1030\verb!+! & addition \\ \hline
1208 1031
@@ -1241,10 +1064,82 @@ or \verb!help insertion!.
1241\subsection{Indexing in matrices} 1064\subsection{Indexing in matrices}
1242Indexing in matrices can be done by giving the indices of selected 1065Indexing in matrices can be done by giving the indices of selected
1243rows and columns or by boolean indices or by using the \verb!$! symbol. 1066rows and columns or by boolean indices or by using the \verb!$! symbol.
1067Here is a sample of commands:
1244\input{diary/extract.dia} 1068\input{diary/extract.dia}
1245 1069
1246\subsection{Indexing in lists} 1070\subsection{Indexing in lists}
1247The following session illustrates how to create lists and 1071The following session illustrates how to create lists and
1248insert/extract entries in {\tt list} and {\tt tlist} or {\tt mlist}. 1072insert/extract entries in {\tt list} and {\tt tlist} or {\tt mlist}.
1249Enter {\tt help insertion} and {\tt help extraction} for additinal examples. 1073Enter {\tt help insertion} and {\tt help extraction} for additinal examples.
1074Below is a sample of commands:
1250\input{diary/list.dia} 1075\input{diary/list.dia}
1076
1077\subsection{Structs and Cells \`a la Matlab}
1078The command {\tt X=tlist(...)} or {\tt Y=mlist(...)} creates a
1079Scilab variable X of type {\tt tlist} or {\tt mlist}.
1080The entries of {\tt X} are obtained by the names of their fields.
1081
1082For instance, if {\tt X=tlist(['mytype','a','b'],A,B)} the command
1083X.a returns A. If A is a matrix the command X.a(2,3) returns the
1084entry at row 2 and column 3 of X;a, i.e. {\tt A(2,3)}.
1085Similarly, if {\tt Y=mlist(['mytype','a','b'],A,B)}, we can use the
1086syntax Y(2,3), once the extraction function \verb! %mytype_e(varargin)!
1087has been defined.
1088
1089Also the syntax {\tt Y(2,3)=33} can be given a meaning
1090through the function \verb!%s_i_mytype(varargin)!.
1091This powerful overloading mechanism allows to define complex objects
1092with a general indexing where indices can be fields (string) or a set
1093of integers.
1094
1095If the variable X is not defined in the Scilab workspace, then
1096the command X.a=A creates a particular mlist which behaves as
1097a Matlab struct. Its internal representation is similar to
1098{\tt X=mlist(['st','dims','a'],int32([1,1]),A)}.
1099It is a one dimensional {\tt struct} with one field called 'a' and
1100the value of X.a is A.
1101Multidimensional structs are created and manipulated in a similar way.
1102For instance {\tt X(2,3).a.b(2)=4} creates a 2 x 3 struct with one field
1103a. It is represented as
1104\begin{verbatim}
1105mlist(['st','dims','a'],int32([2,3]),list([],[],[],[],[],w))
1106\end{verbatim}
1107where w is a struct with one field 'b', and w.b is the vector [0,4].
1108A particular display is done for structs. Here, we have:
1109\begin{verbatim}
1110-->X(2,3)
1111 ans =
1112
1113 a: [1x1 struct]
1114
1115-->X(2,3).a
1116 ans =
1117
1118 b: [0;4]
1119\end{verbatim}
1120
1121All the struct manipulations are implemented by soft coded operations
1122i.e. Scilab overloaded functions. As structs are not basic data types
1123some operations are slow. They have been implemented for a better
1124Matlab compatibility.
1125
1126The Matlab cells are also easily emulated. A cell is seen as a particular
1127struct with one field called 'entries'. We just show a simple example:
1128
1129\begin{verbatim}
1130
1131-->X=cell(1,2)
1132 X =
1133
1134!{} {} !
1135
1136-->X(2).entries=11
1137 X =
1138
1139!{} !
1140! !
1141!11 !
1142\end{verbatim}
1143
1144Note that Matlab uses braces \verb!X{2}! for extracting entries from
1145a cell.
diff --git a/scilab_doc/intro/chap3.tex b/scilab_doc/intro/chap3.tex
index 19dff2a..fcd1734 100755
--- a/scilab_doc/intro/chap3.tex
+++ b/scilab_doc/intro/chap3.tex
@@ -4,22 +4,22 @@
4\label{ch4} 4\label{ch4}
5\index{programming} 5\index{programming}
6 6
7 One of the most useful features of Scilab is its ability 7 One of the most useful features of Scilab is its ability
8to create and use functions. This allows the development of specialized 8to create and use functions. This allows the development of specialized
9programs which can be integrated into the Scilab package in a simple and 9programs which can be integrated into the Scilab package in a simple and
10modular way through, for example, the use of libraries. In this chapter we 10modular way through, for example, the use of libraries. In this chapter we
11treat the following subjects: 11treat the following subjects:
12\begin{itemize} 12\begin{itemize}
13 \item Programming Tools 13 \item Programming Tools
14 \item Defining and Using Functions 14 \item Defining and Using Functions
15 \item Definition of Operators for New Data Types 15 \item Definition of Operators for New Data Types
16 \item{Debbuging} 16 \item{Debbuging}
17\end{itemize} 17\end{itemize}
18Creation of libraries is discussed in a later chapter. 18Creation of libraries is discussed in a later chapter.
19 19
20\section{Programming Tools} 20\section{Programming Tools}
21 21
22 Scilab supports a full list of programming tools 22 Scilab supports a full list of programming tools
23including loops, conditionals, case selection, 23including loops, conditionals, case selection,
24and creation of new environments. Most programming tasks 24and creation of new environments. Most programming tasks
25should be accomplished in the environment of a function. 25should be accomplished in the environment of a function.
@@ -98,7 +98,7 @@ matrices. The index takes as values the entries of the list.
98 str 98 str
99\end{verbatim} 99\end{verbatim}
100 100
101 The {\tt while} loop repeatedly performs a sequence of commands 101 The {\tt while} loop repeatedly performs a sequence of commands
102until a condition is satisfied. 102until a condition is satisfied.
103\begin{verbatim} 103\begin{verbatim}
104--> x=1; while x<14,x=2*x,end 104--> x=1; while x<14,x=2*x,end
@@ -182,7 +182,7 @@ has the usual meaning and is a also a keyword recognized by the interpreter.
182\end{verbatim} 182\end{verbatim}
183 183
184 184
185 The {\tt select}-{\tt case} conditional 185 The {\tt select}-{\tt case} conditional
186compares an expression to several possible expressions and performs the 186compares an expression to several possible expressions and performs the
187instructions following the first case which equals the initial expression. 187instructions following the first case which equals the initial expression.
188\begin{verbatim} 188\begin{verbatim}
@@ -206,7 +206,7 @@ where none of the cases are satisfied.
206\index{functions} 206\index{functions}
207\index{functions!definition} 207\index{functions!definition}
208 208
209 It is possible to define a function directly in 209 It is possible to define a function directly in
210the Scilab environment, however, the most convenient way 210the Scilab environment, however, the most convenient way
211is to create a file containing the function 211is to create a file containing the function
212with a text editor. In this section we describe the 212with a text editor. In this section we describe the
@@ -380,16 +380,16 @@ Scilab has several special commands which are used almost exclusively
380in functions. These are the commands 380in functions. These are the commands
381 381
382\begin{itemize} 382\begin{itemize}
383 \item {\tt argn}\index{argn@{\tt argn}}: returns the number of input 383 \item {\tt argn}\index{argn@{\tt argn}}: returns the number of input
384and output arguments for the function 384and output arguments for the function
385 \item {\tt error}\index{error@{\tt error}}: used to suspend the 385 \item {\tt error}\index{error@{\tt error}}: used to suspend the
386operation of a function, to print an error message, and to return to the 386operation of a function, to print an error message, and to return to the
387previous level of environment when an error is detected. 387previous level of environment when an error is detected.
388 \item {\tt warning}\index{warning@{\tt warning}}, 388 \item {\tt warning}\index{warning@{\tt warning}},
389 \item {\tt pause}\index{pause@{\tt pause}}: temporarily suspends the 389 \item {\tt pause}\index{pause@{\tt pause}}: temporarily suspends the
390operation of a function. 390operation of a function.
391 \item {\tt break}\index{break@{\tt break}}: forces the end of a loop 391 \item {\tt break}\index{break@{\tt break}}: forces the end of a loop
392 \item {\tt return}\index{return@{\tt return}} or {\tt resume} : used 392 \item {\tt return}\index{return@{\tt return}} or {\tt resume} : used
393to return to the calling environment and to pass local 393to return to the calling environment and to pass local
394variables from the function environment to the calling environment. 394variables from the function environment to the calling environment.
395\end{itemize} 395\end{itemize}
@@ -455,7 +455,7 @@ the global environment.
455\label{s4.3} 455\label{s4.3}
456\index{operations!for new data types} 456\index{operations!for new data types}
457 457
458 It is possible to transparently define fundamental operations 458 It is possible to transparently define fundamental operations
459for new data types in Scilab (enter {\tt help overloading} for 459for new data types in Scilab (enter {\tt help overloading} for
460a full description of this feature). 460a full description of this feature).
461That is, the user can give a sense to multiplication, division, addition, etc. 461That is, the user can give a sense to multiplication, division, addition, etc.
@@ -467,7 +467,7 @@ Scilab performs these user defined operations by searching for functions
467(written by the user) which follow a special naming convention described 467(written by the user) which follow a special naming convention described
468below. 468below.
469 469
470 The naming convention Scilab uses to recognize operators 470 The naming convention Scilab uses to recognize operators
471defined by the user is determined by the following conventions. The name 471defined by the user is determined by the following conventions. The name
472of the user defined function is composed of four (or possibly three) 472of the user defined function is composed of four (or possibly three)
473fields. The first field is always the symbol {\tt \%}. 473fields. The first field is always the symbol {\tt \%}.
@@ -593,7 +593,7 @@ representing a linear system has the form: \\
593 and, thus, the {\tt xxx} 593 and, thus, the {\tt xxx}
594above is {\tt lss}. 594above is {\tt lss}.
595 595
596 An example of the function name which multiplies two 596 An example of the function name which multiplies two
597linear systems together (to represent their series inter-connection) 597linear systems together (to represent their series inter-connection)
598is {\tt \%lss\_m\_lss}. Here the first field is \%, the second field is 598is {\tt \%lss\_m\_lss}. Here the first field is \%, the second field is
599{\tt lss} (linear state-space), the third field is {\tt m} ``multiply'' 599{\tt lss} (linear state-space), the third field is {\tt m} ``multiply''
diff --git a/scilab_doc/intro/chap4.tex b/scilab_doc/intro/chap4.tex
index 2e998bc..8b90c50 100755
--- a/scilab_doc/intro/chap4.tex
+++ b/scilab_doc/intro/chap4.tex
@@ -1,5 +1,3 @@
1% Copyright INRIA
2
3\chapter{Basic Primitives} 1\chapter{Basic Primitives}
4\label{ch5} 2\label{ch5}
5This chapter briefly describes some basic primitives of Scilab. 3This chapter briefly describes some basic primitives of Scilab.
@@ -125,6 +123,58 @@ mfprintf}\index{mfprintf@{\tt mfprintf}} can be also used
125--> mclose(fd) 123--> mclose(fd)
126\end{verbatim} 124\end{verbatim}
127 125
126Here is a table of useful input-output functions:
127
128\begin{center}
129\begin{tabular}{|c|c|}
130\hline
131\verb!mprintf! & print in standard output\\ \hline
132
133\verb!mfprintf! & print in a file\\ \hline
134
135\verb!msprintf! & print in a string matrix \\ \hline
136
137\verb!mscanf! & read in standard input \\ \hline
138
139\verb!mfscanf! & read in a file \\ \hline
140
141\verb!msscanf! & read in a string matrix \\ \hline
142
143\verb!fprintfMat! & formated write a matrix into a file \\ \hline
144
145\verb!fscanfMat! & formated read of a matrix in a file \\ \hline
146
147\verb!mgetl! & read a file as a Scilab string matrix \\ \hline
148
149\verb!mputl! & write a string matrix \\ \hline
150
151\verb!mopen! & open a file \\ \hline
152
153\verb!mclose! & close a file\\ \hline
154\end{tabular}
155\end{center}
156
157To manipulate binary files, the following functions are available:
158\begin{center}
159\begin{tabular}{|c|c|}
160\hline
161\verb!mget! & read binary data\\ \hline
162
163\verb!mput! & write binary data\\ \hline
164
165\verb!mgetstr! & print in a string matrix \\ \hline
166
167\verb!mputstr! & write a string matrix \\ \hline
168
169\verb!mgetstr! & read in a file \\ \hline
170
171\verb!mtell! & current position in a file\\ \hline
172
173\verb!mseek! & move current position \\ \hline
174
175\verb!meof! & end of file test \\ \hline
176\end{tabular}
177\end{center}
128 178
129\section{Help} 179\section{Help}
130On-line help is available either by clicking on the 180On-line help is available either by clicking on the
@@ -156,25 +206,27 @@ can be obtained by entering {\tt help}. For each manual entry the
156\begin{itemize} 206\begin{itemize}
157\item{Elementary functions: {\tt sum, prod, sqrt, diag, cos, max, round, sign, fft}} 207\item{Elementary functions: {\tt sum, prod, sqrt, diag, cos, max, round, sign, fft}}
158\item{Sorting: {\tt sort, gsort, find}} 208\item{Sorting: {\tt sort, gsort, find}}
159\item{Specific Matrices: {\tt zeros, eye, ones, matrix, empty}} 209\item{Specific Matrices: {\tt zeros, eye, ones, matrix}}
160\item{Linear Algebra: {\tt det, inv, qr, svd, bdiag, spec, schur}} 210\item{Linear Algebra: {\tt det, inv, qr, svd, bdiag, spec, schur}}
161\item{Polynomials}: {\tt poly, roots, coeff, horner, clean, freq} 211\item{Polynomials}: {\tt poly, roots, coeff, horner, clean, freq}
162\item{Buttons, dialog: \verb!x_choose, x_dialog, x_mdialog, getvalue, addmenu!} 212\item{Buttons, dialog: \verb!x_choose, x_dialog, x_mdialog, getvalue, addmenu!}
213\item{GUI (Tcl-tk): \verb!TK_EvalStr, TK_GetVar, TK_SetVar, TK_EvalFile!}
163\item{Linear systems: {\tt syslin}} 214\item{Linear systems: {\tt syslin}}
164\item{Random numbers: {\tt rand}} 215\item{Random numbers: {\tt rand}, {\tt grand}}
165\item{Programming: {\tt function, deff, argn, for, if, end, while, 216\item{Programming: {\tt function, deff, argn, for, if, end, while,
166select, warning, error, break, return}} 217select, warning, error, break, return}}
167\item{Comparison symbols: {\tt ==}, {\tt >=}, {\tt >}, {\tt ~=}, {\verb!&!} 218\item{Comparison symbols: {\tt ==}, {\tt >=}, {\tt >}, {\tt ~=}, {\verb!&!}
168({\tt and}),{\tt |} ({\tt or})} 219({\tt and}),{\tt |} ({\tt or})}
169\item{Execution of a file: {\tt exec}} 220\item{Execution of a file: {\tt exec}}
170\item{Debugging: {\tt pause, return, abort}} 221\item{Debugging: {\tt pause, return, abort}}
171\item{Spline functions, interpolation: {\tt splin, interp, interpln}} 222\item{Spline functions, interpolation: {\tt splin2d, interp2d, smooth, splin3d}}
172\item{Character strings: {\tt string, part, evstr, execstr}} 223\item{Character strings: {\tt string, part, evstr, execstr, grep}}
173\item{Graphics: {\tt plot, xset, driver, plot2d, xgrid, locate, plot3d, Graphics}} 224\item{Graphics: {\tt plot2d, set, get, xgrid, locate, plot3d, Graphics}}
174\item{Ode solvers: {\tt ode, dassl, dassrt, odedc}} 225\item{Ode solvers: {\tt ode, dassl, dassrt, odedc}}
175\item{Optimization: {\tt optim, quapro, linpro, lmitool}} 226\item{Optimization: {\tt optim, quapro, linpro, lmitool, lsqrsolve}}
176\item{Interconnected dynamic systems: {\tt scicos}} 227\item{Interconnected dynamic systems: {\tt scicos}}
177\item{Adding a C or Fortran routine: {\tt link, fort, addinter, intersci}} 228\item{Adding a C or Fortran routine: {\verb!link, call, addinter, ilib_for_link, ilib_build!}}
229\item{Graphs, networks: {\verb! edit_graph, metanet!}}
178\end{itemize} 230\end{itemize}
179 231
180 232
@@ -236,9 +288,6 @@ permanent manner by inserting it in a specific interface in
236{\tt SCIDIR/routines/default} and rebuild a new Scilab by a 288{\tt SCIDIR/routines/default} and rebuild a new Scilab by a
237{\tt make all} command in the Scilab directory. 289{\tt make all} command in the Scilab directory.
238 290
239
240
241
242\section{XWindow Dialog} 291\section{XWindow Dialog}
243It may be convenient to open a specific XWindow window for entering 292It may be convenient to open a specific XWindow window for entering
244interactively parameters inside a function or for a demo. 293interactively parameters inside a function or for a demo.
@@ -253,3 +302,18 @@ A Graphic User Interface object can be created by the function
253\verb!uicontrol!. Basic primitives are \verb!TK_EvalFile!, 302\verb!uicontrol!. Basic primitives are \verb!TK_EvalFile!,
254\verb!TK_EvalStr! and \verb! TK_GetVar, TK_Setvar!. Examples 303\verb!TK_EvalStr! and \verb! TK_GetVar, TK_Setvar!. Examples
255are given by invoking the help of these functions. 304are given by invoking the help of these functions.
305
306Let us give a simple dialog. We pass a script to TK as a Scilab
307string matrix, TK opens a dialog box, and the result is returned
308to Scilab as a string, using \verb!TK_GetVar!.
309\begin{verbatim}
310-->TK_script=["toplevel .dialog";
311 "label .dialog.1 -text ""Enter your input\n here""";
312 "pack .dialog.1";
313 "entry .dialog.e -textvariable scivar";
314 "set scivar """"";
315 "pack .dialog.e"];
316-->TK_EvalStr(TK_script);
317-->text=TK_GetVar(scivar);
318\end{verbatim}
319
diff --git a/scilab_doc/intro/chap5.tex b/scilab_doc/intro/chap5.tex
index 8404dca..52e30f9 100755
--- a/scilab_doc/intro/chap5.tex
+++ b/scilab_doc/intro/chap5.tex
@@ -1,1081 +1,329 @@
1% Copyright INRIA 1\chapter{Graphics}\label{Graphics}
2 2The graphics primitives in Scilab release 3.0 accept two graphic ``styles'',
3\chapter{Graphics} 3the ``old'' style which is based on a pre-processing treatment
4This section introduces graphics in Scilab. 4and the ``new'' style, used by default, which is based on an object
5 5oriented environment.
6\section{The Graphics Window} 6
7It is possible to use several graphics windows {\tt ScilabGraphicx} x being 7These two styles are not fully compatible. To switch to the old style,
8the number used for the management of the windows, but at any time only 8use the command \verb!set old_style on!.
9one window is active. On the main Scilab window the button 9
10 {\tt Graphic Window x} is used to manage the windows : x denotes the 10The old style mode is essentially based on two functions,
11number of the active window, and we can set (create), raise or delete 11{\tt xset} and {\tt xsetech} which act on the graphic environment.
12the window numbered x : in particular we can directly create the 12Once the graphic environment parameters are set, the graphic commands
13graphics window numbered 10. 13are used for plotting.
14The execution of a plotting command automatically creates a window if 14
15necessary. 15In the new style mode, once the plotting command is issued, it is
16 16possible to act on the graphic environment by changing the
17We will see later that Scilab uses a {\tt graphics environment} 17properties of the graphic objects made by the plot command.
18defining some parameters of the plot, these parameters have default 18The graphic environment is post-processed.
19values and can be changed by the user; every graphics window has its 19
20specific context so the same plotting command van give different 20%Nouvelles primitives
21results on different windows. 21%set get draw drawlater drawnow move copy delete glue unglue
22 22%Nouvelles macros
23There are 4 buttons on the graphics window: 23%gcf gca gdf gda sdf sda clearpixmap showpixmap
24\begin{itemize} 24
25 \item \verb+3D Rot.+: for applying a rotation with the mouse to a 25%primitives obsolete pour le nouveau graphique
263D plot. This button is inhibited for a 2D plot. For the help of 26%xset (sauf 'window' et 'alufunction')
27manipulations (rotation with specific angles ...) the rotation angles 27%xget (sauf 'window' et 'alufunction')
28are given at the top of the window. 28%xtape xname xgrid replot isoview
29 \item \verb+2D Zoom+: zooming on a 2D plot. This command can be 29
30recursively invoked. For a 3D plot this button is not inhibited but it 30Scilab graphics are based on a set a graphics functions such as {\tt plot2d},
31has no effect. 31{\tt plot3d} \ldots and an object oriented graphic environment.
32 \item \verb+UnZoom+: return to the initial plot (not to the plot 32The properties of the graphic objects (color, thickness, ...) are manipulated
33corresponding to the previous zoom in case of multiple zooms). 33with the functions {\tt get} and {\tt set}. The main graphic objects
34 34are the figure entity and the axes entity.
35These 3 buttons affecting the plot in the window are not always in 35We give here a description of the most useful functions illustrated by
36use; we will see later that there are different choices for the 36simple examples. For more sophisticated examples, it is necessary to read
37underlying device and zoom and rotation need the record of the 37the on-line help pages. The graphic demos are also useful and it is
38plotting commands which is one of the possible choices (this is the 38a good way to start.
39default). 39
40 40\section{Function plot2d}
41 41The basic graphic function \index{plot2d@\scilab{plot2d}} used
42 \item \verb+File+: this button opens different commands and menus. 42for plotting one or several 2D curves is \scifun{plot2d}.
43 43The simplest graphic command is \scilab{plot2d(x,y)} where
44The first one is simple : {\tt Clear} simply rubs out the window 44x and y are two vectors with same dimension.
45(without affecting the graphics context of the window). 45This command gives the graph of the polyline which links each
46 46point with coordinates \scilab{(x(i),y(i))} with the next point
47The command {\tt Print...} opens a selection panel for printing. 47with coordinates \scilab{(x(i+1),y(i+1))}. The vectors
48Under Unix, the printers are defined in the main scilab script 48\scilab{x} et \scilab{y} must have at least two components.
49{\tt SCIDIR/bin/scilab} (obtained by ``make all'' from the origin 49The vector \scilab{x} can be omitted, its default value being
50file {\tt SCIDIR/bin/scilab.g}). 50\scilab{1:n} where \scilab{n} is the size of \scilab{y}.
51 51\begin{figure}
52The {\tt Export} command opens a panel selection for getting a copy of the 52\begin{center}
53plot on a file with a specified format (Postscript, Postscript-Latex, Xfig). 53%\includegraphics[width=10cm]{figures/graphique0.eps}
54 54\includegraphics[width=10cm,height=7.6cm]{figures/f0.eps}
55The {\tt save} command directly saves the plot on a file with a 55\end{center}
56specified name. This file can be loaded later in Scilab for replotting. 56\caption{A simple graph}
57 57\label{f0}
58The {\tt Close} is the same command than the previous {\tt Delete
59Graphic Window} of the menu of the main window, but simply
60applied to its window (the graphic context is, of course deleted).
61
62\end{itemize}
63
64
65\section{The Media}
66There are different graphics devices in Scilab which can be used to send
67graphics to windows or paper. The default for the output is
68\verb+ScilabGraphic0+ window .
69
70\noindent The different drivers are:
71
72%
73\begin{itemize}
74 \item \verb+X11+ : memoryless screen graphics driver
75 \item \verb+Rec+ : a screen driver which also
76 records all the graphic commands. This is the default
77 (required for the zoom and rotate).
78 \item \verb+Wdp+ : a screen driver without recorded
79 graphics; the graphics are done on a pixmap and are send to
80 the graphic window with the command {\tt xset("wshow")}. The
81 pixmap is cleared with the command {\tt xset("wwpc")} or with the
82 usual command {\tt xbasc()}
83 \item \verb+Pos+ : graphics driver for Postscript printers
84 \item \verb+Fig+ : graphics driver for the Xfig system
85 \item \verb+GIF+ : graphics driver for the GIF file format
86\end{itemize}
87%
88
89In the 3 first cases the 'implicit' device is a graphics window
90(existing or created by the plot). For the 2 last cases we will see
91later how to affect a specific device to the plot : a file where the
92plot will be recorded in the Postscript or Xfig format.
93
94The basic Scilab graphics commands are :
95%
96\begin{itemize}
97 \item \verb+driver+: selects a graphic driver
98
99The next 3 commands are specific of the screen drivers :
100
101 \item \verb+xclear+: clears one or more graphic windows; does
102 not affect the graphics context of these windows.
103 \item \verb+xbasc+: clears a graphic window and erase the
104 recorded graphics; does not affect the graphics context of
105 the window.
106 \item \verb+xpause+: a pause in milliseconds
107 \item \verb+xselect+: raises the current graphic window
108 (for X-drivers)
109 \item \verb+xclick+: waits for a mouse click
110 \item \verb+xbasr+: redraws the plot of a graphic window
111 \item \verb+xdel+: deletes a graphic window (equivalent to the
112 {\tt Close} button
113
114The following commands are specific of the Postscript, Xfig and GIF drivers
115drivers :
116
117 \item \verb+xinit+: initializes a graphic device (file).
118 \item \verb+xend+: closes a graphic session (and the
119 associated device).
120\end{itemize}
121%
122
123In fact, the regular driver for a common use is {\tt Rec} and there
124are special commands in order to avoid a change of driver; in many
125cases, one can ignore the existence of drivers and use the
126functions \verb+xbasimp+, \verb+xs2fig+ in order to send a graphic
127to a printer or in a file for the \verb+Xfig+ system. For example with
128:
129
130\begin{verbatim}
131-->driver('Pos')
132
133-->xinit('foo.ps')
134
135-->plot(1:10)
136
137-->xend()
138
139-->driver('Rec')
140
141-->plot(1:10)
142
143-->xbasimp(0,'foo1.ps')
144
145\end{verbatim}
146
147\noindent we get two identical Postscript files : {\tt 'foo.ps'} and {\tt 'foo1.ps.0'}
148(the appending 0 is the number of the active window where the plot has been
149done).
150
151The default for plotting is the superposition; this means that between
1522 different plots one of the 2 following command is needed:
153{\tt xbasc(window-number)} which clears the window and erase the
154recorded Scilab graphics command associated with the window
155\verb+window-number+ or {\tt xclear}) which simply clears the window.
156
157If you enlarge a graphic window, the command \verb+xbasr(window-number)+
158is executed by Scilab. This command clears the graphic window
159\verb+window-number+ and replays the graphic commands associated with it. One
160can call this function manually, in order to verify the associated
161recorded graphics commands.
162
163Any number of graphics windows can be created with buttons
164or with the commands \verb+xset+ or \verb+xselect+. The environment
165variable DISPLAY can be used to specify an X11 Display or one can use
166the \verb+xinit+ function in order to open a graphic window on a
167specific display.
168
169\section{Global Parameters of a Plot}
170\subsubsection{Graphics Context}
171
172Some parameters of the graphics are controlled by a graphic context
173( for example the line thickness) and others are controlled through
174graphics arguments of a plotting command.
175The graphics context has a default definition and can be change by the
176command {\tt xset} : the command without argument i.e. {\tt xset()}
177opens the {\tt Scilab Toggles Panel} and the user can changes the
178parameters by simple mouse clickings. We give here different
179parameters controlled by this command :
180%
181\begin{itemize}
182 \item {\tt xset} : set graphic context values.
183
184(i)-{\tt xset("font",fontid,fontsize)} : fix the current font and
185its current size.
186
187(ii)-{\tt xset("mark",markid,marksize)} : set the current mark
188and current mark size.
189
190(iii)-{\tt xset("use color",flag)} : change to color or gray plot according to
191the values (1 or 0) of {\tt flag}.
192
193(iv)-{\tt xset("colormap",cmap)} : set the colormap as a m x 3
194matrix. m is the number of colors. Color number i is given as a
1953-uple cmap[i,1],cmap[i,2], cmap[i,3] corresponding respectively to Red,
196Green and Blue intensity between 0 and 1. Calling again {\tt xset()}
197shows the colormap with the indices of the colors.
198
199(v)-{\tt xset("window",window-number)} : sets the current window to the window \\
200{\tt window-number} and creates the window if it doesn't exist.
201
202(vi)-{\tt xset("wpos",x,y)} : fixes the position of the upper left point of
203the graphic window.
204
205Many other choices are done by {\tt xset} :
206
207-use of a pixmap : the plot can be directly displayed on the screen or
208executed on a pixmap and then expose by the command
209{\tt xset("wshow")}; this is the usual way for animation effect.
210
211-logical function for drawing : this parameter can be changed for
212specific effects (superposition or adding or substracting of colors).
213Looking at the successive plots of the following simple commands give
214an example of 2 possible effects of this parameter :
215
216\begin{verbatim}
217xset('default');
218plot3d();
219plot3d();
220xset('alufunction',7);
221xset('window',0);
222plot3d();
223xset('default');
224plot3d();
225xset('alufunction',6);
226xset('window',0);
227plot3d();
228\end{verbatim}
229
230We have seen that some choices exist for the fonts and this choice can
231be extended by the command:
232 \item {\tt xlfont} : to load a new family of fonts
233
234
235There exists the function ``reciprocal'' to {\tt xset} :
236
237 \item {\tt xget} : to get informations about the
238 current graphic context.
239
240All the values of the parameters fixed by {\tt xset} can be obtained by
241{\tt xget}. An example :
242
243\begin{verbatim}
244
245-->pos=xget("wpos")
246 pos =
247
248! 105. 121. !
249
250\end{verbatim}
251
252{\tt pos} is the position of the upper left point of the graphic window.
253\end{itemize}
254%
255
256\subsubsection{Some Manipulations}
257
258Coordinates transforms:
259\begin{itemize}
260
261\item \verb+isoview+ : isometric scale without window change
262
263allows an isometric scale in the window of previous plots without changing
264the window size:
265
266\begin{verbatim}
267
268t=(0:0.1:2*%pi)';
269plot2d(sin(t),cos(t));
270xbasc()
271isoview(-1,1,-1,1);
272plot2d(sin(t),cos(t));
273
274\end{verbatim}
275
276\item \verb+square+ : isometric scale with resizing the window
277
278the window is resized according to the parameters of the command.
279
280\item \verb+scaling+ : scaling on data
281\item \verb+rotate+ : rotation
282
283\verb+scaling+ and \verb+rotate+ executes respectively an affine transform and
284a geometric rotation of a 2-lines-matrix corresponding to the {\tt (x,y) }
285values of a set of points.
286\item \verb+xgetech, xsetech+ : change of scale inside the graphic window
287
288The current graphic scale can be fixed by a high level plot command. You may
289want to get this parameter or to fix it directly : this is the role of
290\verb+xgetech, xsetech+ . {\tt xsetech } is a simple way to cut the
291window in differents parts for different plots :
292
293\begin{verbatim}
294
295t=(0:0.1:2*%pi)';
296xsetech(wrect=[0.,0.,0.6,0.3],frect=[-1,1,-1,1]);
297plot2d(sin(t),cos(t));
298xsetech(wrect=[0.5,0.3,0.4,0.6],frect=[-1,1,-1,1]);
299plot2d(sin(t),cos(t));
300
301\end{verbatim}
302
303\end{itemize}
304%
305
306
307\section{2D Plotting}
308
309\subsection{Basic 2D Plotting}
310
311The simplest 2D plot is {\tt plot(x,y)} or {\tt plot(y)}: this is the plot of
312{\tt y} as function of {\tt x} where {\tt x} and {\tt y} are 2 vectors; if
313{\tt x} is missing, it is replaced by the vector {\tt (1,size(y,'*')))}.
314If {\tt y} is a matrix, its rows are plotted. There are optional arguments.
315
316
317A first example is given by the following commands and one of the results is
318represented on figure \ref{d7-1}:
319
320\begin{verbatim}
321
322t=(0:0.05:1)';
323ct=cos(2*%pi*t);
324// plot the cosine
325plot(t,ct);
326// xset() opens the toggle panel and
327// some parameters can be changed with mouse clicks
328// given by commands for the demo here
329xset("font",5,4);xset("thickness",3);
330// plot with captions for the axis and a title for the plot
331// if a caption is empty the argument ' ' is needed
332plot(t,ct,'Time','Cosine','Simple Plot');
333// click on a color of the xset toggle panel and do the previous plot again
334// to get the title in the chosen color
335
336\end{verbatim}
337
338\input{figures/d7-1.tex}
339\caption{\label{d7-1}First example of plotting}
340%\dessin{First example of plotting}{d7-1}
341\end{figure} 58\end{figure}
342 59
343\noindent The generic 2D multiple plot is 60Let us start with a simple example. Entering the commands
344
345
346\noindent {\tt plot2di(x,y,<options>)}
347
348\begin{itemize}
349
350\item index of \verb+plot2d+ : {\tt i=missing,2,3,4}.
351
352For the different values of {\tt i} we have:
353
354 {\tt i=missing} : piecewise linear/logarithmic plotting
355
356 {\tt i=2} : piecewise constant drawing style
357
358 {\tt i=3} : vertical bars
359
360 {\tt i=4} : arrows style (e.g. ode in a phase space)
361
362\end{itemize}
363
364\begin{verbatim}
365t=(1:0.1:8)';xset("font",2,3);
366subplot(2,2,1)
367plot2d([t t],[1.5+0.2*sin(t) 2+cos(t)]);
368xtitle('Plot2d-Piecewise linear');
369//
370subplot(2,2,2)
371plot2d(t,[1.5+0.2*sin(t) 2+cos(t)],logflag='ll');
372xtitle('Plot2d1-Logarithmic scales');
373//
374subplot(2,2,3)
375plot2d2(t,[1.5+0.2*sin(t) 2+cos(t)]);
376xtitle('Plot2d2-Piecewise constant');
377//
378subplot(2,2,4)
379plot2d3(t,[1.5+0.2*sin(t) 2+cos(t)]);
380xtitle('Plot2d3-Vertical bar plot')
381\end{verbatim}
382
383\input{figures/nouv1.tex}
384
385\begin{itemize}
386
387
388\item Parameters {\tt x,y} : two matrices of the same size {\tt [nl,nc]} ({\tt nc}
389is the number of curves and {\tt nl} is the number of points of each
390curve).
391
392For a single curve the vector can be row or column: \\
393{\tt plot2d(t',cos(t)') plot2d(t,cos(t))} are equivalent.
394
395
396\item option {\tt style} :it is a real vector of size {\tt
397(1,nc)}; the style
398to use for curve j is defined by {\tt size(j)} (when only one curve is drawn
399{\tt style} can specify the style and a position to use for the
400caption).
401
402\begin{verbatim}
403xmax=5.;x=0:0.1:xmax;
404u=[-0.8+sin(x);-0.6+sin(x);-0.4+sin(x);-0.2+sin(x);sin(x)];
405u=[u;0.2+sin(x);0.4+sin(x);0.6+sin(x);0.8+sin(x)]';
406//start trying the symbols (negative values for the style)
407
408plot2d(x,u,style=[-9,-8,-7,-6,-5,-4,-3,-2,-1,0])
409
410x=0:0.2:xmax;
411v=[1.4+sin(x);1.8+sin(x)]';
412xset("mark size",5);
413plot2d(x,v,style=[-7,-8])
414xset('default');
415\end{verbatim}
416
417\input{figures/nouv2.tex}
418
419\item Option {\tt frameflag} : is a scalar corresponding to :
420
421\begin{tabular}{|l|l|l|l|} \hline
422 requirements&ranges &ranges &ranges \\
423 &of a previous&given by &computed from\\
424actual &plot &rect arg &x and y \\ \hline
425requested & & & \\
426one & 0 & 1 & 2 \\ \hline
427Computed & & & \\
428for isometric & & 3 & 4 \\
429view & & & \\ \hline
430Enlarged & & & \\
431For pretty & & 5 & 6 \\
432axes & & & \\ \hline
433Previous and & & & \\
434current & & 7 & 8 \\
435plots merged & & & \\ \hline
436\end{tabular}
437\item Option {\tt axesflag} controls the display of information on the frame around the plot :
438\begin{itemize}
439\item 0
440:
441nothing is drawn around the plot.
442\item 1
443:
444axes are drawn, the y=axis is displayed on the left.
445\item 2
446:
447the plot is surrounded by a box without tics.
448\item 3
449:
450axes are drawn, the y=axis is displayed on the right.
451\item 4
452:
453axes are drawn centred in the middle of the frame box.
454
455\item 5
456:
457axes are drawn so as to cross at point {\tt (0,0)}. If point
458{\tt (0,0)} does not lie inside the frame, axes will not appear on the graph.
459\end{itemize}
460
461\item Option {\tt leg } : it is the string of the captions for the different
462plotted curves . This string is composed of fields separated by the {\tt @}
463symbol: for example {\tt ``module@phase''} (see example below). These
464strings are
465displayed under the plot with small segments recalling the styles of the
466corresponding curves.
467
468\item Option {\tt rect } : it is a vector of 4 values specifying the boundaries
469of the plot {\tt rect=[xmin,ymin,xmax,ymax]}.
470
471\item Option {\tt nax } : it is a vector [nx,Nx,ny,Ny] where nx (ny) is
472the number of subgrads on the x (y) axis and Nx (Ny) is the number of
473graduations on the x (y) axis.
474
475\end{itemize}
476
477\begin{verbatim}
478
479//captions for identifying the curves
480//controlling the boundaries of the plot and the tics on axes
481x=-5:0.1:5;
482y1=sin(x);y2=cos(x);
483X=[x;x]; Y=[y1;y2];
484plot2d(X',Y',style=[-1 -3]',leg="caption1@caption2",...
485rect=[-5,-1,5,1],nax=[2,10,5,5]);
486
487\end{verbatim}
488
489\input{figures/nouv3.tex}
490
491
492For different plots the simple commands without any argument show a demo
493(e.g {\tt plot2d3()} ).
494
495\subsection{Captions and Presentation}
496%
497\begin{itemize}
498\item \verb+xgrid+ : adds a grid on a 2D graphic; the
499calling parameter is the number of the color.
500\item \verb+xtitle+ : adds title above the plot and axis
501names on a 2D graphic
502\item \verb+titlepage+ : graphic title page in the middle of
503the plot
504
505\begin{verbatim}
506
507//Presentation
508x=-%pi:0.1:%pi;
509y1=sin(x);y2=cos(x);y3=x;
510X=[x;x;x]; Y=[y1;y2;y3];
511plot2d(X',Y',style=[-1 -2 -3],leg="caption1@caption2@caption3",...
512rect=[-3,-3,3,2],nax=[2,10,2,5]);
513xtitle(["General Title";"(with xtitle command)"],...
514"x-axis title","y-axis title (with xtitle command)");
515xgrid();
516xclea(-2.7,1.5,1.5,1.5);
517titlepage("Titlepage");
518xstring(0.6,.45,"(with titlepage command)");
519xstring(0.05,.7,["xstring command after";"xclea command"],0,1);
520plot2d(X',Y',style=[-1 -2 -3],leg="caption1@caption2@caption3",...
521rect=[-3,-3,3,2],nax=[2,10,2,5]);
522
523\end{verbatim}
524
525\input{figures/nouv4.tex}
526
527
528 \item \verb+plotframe+ : graphic frame with scaling and grid
529\end{itemize}
530%
531
532We have seen that it is possible to control the tics on the axes,
533choose the size of the rectangle for the plotand add a grid.
534This operation can be prepared once and then used for a sequence of
535different plots. One of the most useful aspect is to get graduations
536by choosing the number of graduations and getting rounded numbers.
537
538\begin{verbatim} 61\begin{verbatim}
539 62-->x=linspace(0,2*%pi,100);plot2d(x,sin(x))
540rect=[-%pi,-1,%pi,1];
541tics=[2,10,4,10];
542plotframe(rect,tics,[%t,%t],...
543['Plot with grids and automatic bounds','angle','velocity']);
544
545\end{verbatim} 63\end{verbatim}
546 64opens a graphic window and produces a graph of the sine function
547\begin{itemize} 65for 100 values of x equally spaced between 0 and $2 \pi$.
548 \item \verb+graduate+ : a simple tool for computing pretty 66 The \scilab{plot2d} command opens a graphic window
549axis graduations before a plot. 67(see figure \ref{f0}) in which the plot appears.
550\end{itemize} 68The graph is plotted in a rectangular frame and the bottom and left
551% 69sides are used for axes with ticks.
552 70
553\subsection{Specialized 2D Plottings} 71By default, \scifun{plot2d} does not erase the graphic window, but
554% 72the plot is made in the current windows, which possibly contains older
555\begin{itemize} 73plots. Thus, if after the preceding command the following is entered~:
556 \item \verb+champ+ : vector field in $R^{2}$
557
558\begin{verbatim} 74\begin{verbatim}
559//try champ 75t=linspace(0,4*%pi,100);plot2d(t,0.5*cos(t))
560x=[-1:0.1:1];y=x;u=ones(x);
561fx=x.*.u';fy=u.*.y';
562champ(x,y,fx,fy);
563xset("font",2,3);
564xtitle(['Vector field plot';'(with champ command)']);
565//with the color (and a large stacksize)
566x=[-1:0.004:1];y=x;u=ones(x);
567fx=x.*.u';fy=u.*.y';
568champ1(x,y,fx,fy);
569\end{verbatim} 76\end{verbatim}
77\noindent we get figure \ref{g0}) in which the graph of th
78two functions, sine and cosine, appear with a common x axis.
79(note that the x-axis goes from $0$ to $4\pi$ after the second
80plot command).
81\begin{figure}
82\begin{center}
83%\includegraphics[width=10cm]{figures/graphique0.eps}
84%\includegraphics[width=10cm]{figures/gg.eps}
85\includegraphics[width=10cm]{figures/f1.eps}
86\end{center}
87\caption{Two plots: superposing curves}\label{g0}
88\end{figure}
570 89
571\input{figures/nouv5.tex} 90To clear the graphic window, the command \scifun{xbasc()} should be
572 91used or just click the \scifun{Clear} button of the \scifun{File} menu.
573
574
575 \item \verb+fchamp+ : for a vector field in $R^{2}$ defined by a
576function. The same plot than {\tt champ} for a vector field defined
577for example by a scilab program.
578
579 \item \verb+fplot2d+ : 2D plotting of a curve described by a
580function. This function plays the same role for {\tt plot2d} than the
581previous for {\tt champ}.
582
583 \item \verb+grayplot+ : 2D plot of a surface using gray
584levels; the surface being defined by the matrix of the values
585for a grid.
586
587 \item \verb+fgrayplot+ : the same than the previous for a
588surface defined by a function (scilab program).
589 92
590In fact these 2 functions can be replaced by a usual color plot with 93Using the standard menus, it is possible to zoom a part of the graph or
591an appropriate colormap where the 3 RGB components are the same. 94to export the graphic window into a file or to see the 2D plot in a
953D figure. Menus can be interactively
96added or removed, using \scifun{delmenu} \scifun{addmenu} functions.
592 97
98Parameters such as the color or the thickness of the frame can be
99given to the {\tt plot2d} function. Note that the graphic parameters are
100given to {\tt plot2d} with a particular syntax. For instance to select a
101color or a line style we can use the ``style'' keyword inside the plot2d
102command as follows:
593\begin{verbatim} 103\begin{verbatim}
594R=[1:256]/256;RGB=[R' R' R']; 104-->plot2d(x,y,style=5) //5 means ``red''
595xset('colormap',RGB);
596deff('[z]=surf(x,y)','z=-((abs(x)-1)**2+(abs(y)-1)**2)');
597fgrayplot(-1.8:0.02:1.8,-1.8:0.02:1.8,surf,rect=[-2,-2,2,2]);
598xset('font',2,3);
599xtitle(["Grayplot";"(with fgrayplot command)"]);
600//the same plot can be done with a ``unique'' given color
601R=[1:256]/256;
602G=0.1*ones(R);
603RGB=[R' G' G'];
604xset('colormap',RGB);
605fgrayplot(-1.8:0.02:1.8,-1.8:0.02:1.8,surf,rect=[-2,-2,2,2]);
606\end{verbatim} 105\end{verbatim}
607 106
608%\input{figures/nouv6.tex} 107The basic properties of a figure can be accessed by clicking on the {\tt Edit}
609%\dessin{Gray plot with a gray colormap}{nouv6} 108button of the graphic window. For instance to select a particular color
610 109(as done with style=5 before) we can use the command
611 \item \verb+errbar+ : creates a plot with error bars
612\end{itemize}
613%
614
615
616\subsection{Plotting Some Geometric Figures}
617\subsubsection{Polylines Plotting}
618\begin{itemize}
619 \item \verb+xsegs+ : draws a set of unconnected segments
620 \item \verb+xrect+ : draws a single rectangle
621 \item \verb+xfrect+ : fills a single rectangle
622 \item \verb+xrects+ : fills or draws a set of rectangles
623 \item \verb+xpoly+ : draws a polyline
624 \item \verb+xpolys+ : draws a set of polylines
625 \item \verb+xfpoly+ : fills a polygon
626 \item \verb+xfpolys+ : fills a set of polygons
627 \item \verb+xarrows+ : draws a set of unconnected arrows
628 \item \verb+xfrect+ : fills a single rectangle
629 \item \verb+xclea+ : erases a rectangle on a graphic window
630\end{itemize}
631%
632
633\subsubsection{Curves Plotting}
634\begin{itemize}
635 \item \verb+xarc+ : draws an ellipsis
636 \item \verb+xfarc+ : fills an ellipsis
637 \item \verb+xarcs+ : fills or draws a set of ellipsis
638\end{itemize}
639%
640
641\subsection{ Writting by Plotting}
642%
643\begin{itemize}
644 \item \verb+xstring+ : draws a string or a matrix of strings
645 \item \verb+xstringl+ : computes a rectangle which surrounds
646 a string
647 \item \verb+xstringb+ : draws a string in a specified box
648 \item \verb+xnumb+ : draws a set of numbers
649\end{itemize}
650%
651
652We give now the sequence of the commands for obtaining the
653figure~ \ref{fgeom}.
654
655\begin{verbatim} 110\begin{verbatim}
656// initialize default environment variables 111-->plot2d(x,y)
657xset('default');
658xset("use color",0);
659xset("font",4,3)
660xsetech(frect=[1,1,10,10]);
661xrect(0,1,3,1)
662xfrect(3.1,1,3,1)
663xstring(0.5,0.5,"xrect(0,1,3,1)")
664xstring(4.,0.5,"xfrect(3.1,1,3,1)")
665xset("alufunction",6)
666xstring(4.,0.5,"xfrect(3.1,1,3,1)")
667xset("alufunction",3)
668xv=[0 1 2 3 4]
669yv=[2.5 1.5 1.8 1.3 2.5]
670xpoly(xv,yv,"lines",1)
671xstring(0.5,2.,"xpoly(xv,yv,""lines"",1)")
672xa=[5 6 6 7 7 8 8 9 9 5]
673ya=[2.5 1.5 1.5 1.8 1.8 1.3 1.3 2.5 2.5 2.5]
674xarrows(xa,ya)
675xstring(5.5,2.,"xarrows(xa,ya)")
676xarc(0.,5.,4.,2.,0.,64*300.)
677xstring(0.5,4,"xarc(0.,5.,4.,2.,0.,64*300.)")
678xfarc(5.,5.,4.,2.,0.,64*360.)
679//xset("alufunction",6)
680xclea(5.6,4.4,2.8,0.8);
681xstring(5.8,4.,"xfarc and then xclea")
682//xset("alufunction",3)
683xstring(0.,4.5,"WRITING-BY-XSTRING()",-22.5)
684xnumb([5.5 6.2 6.9],[5.5 5.5 5.5],[3 14 15],1)
685isoview(0,12,0,12)
686xarc(-5.,12.,5.,5.,0.,64*360.)
687xstring(-4.5,9.25,"isoview + xarc",0.)
688A=[" 1" " 2" " 3";" 4" " 5" " 6";"68" " 17.2" " 9"];
689xstring(7.,10.,A);
690rect=xstringl(7,10,A);
691xrect(rect(1),rect(2),rect(3),rect(4));
692\end{verbatim} 112\end{verbatim}
113and select the {\tt Start entity picker} item of the {\tt Edit} button, then
114click on the curve, select a particular color and finally select the
115{\tt Stop entity picker} item.
693 116
694\input{figures/nouv7.tex} 117\section{Figure, axes, etc}
695 118Once a graphic command has been issued, the properties of the figure
696 119obtained are retrieved by the command
697e have seen that some parameters of the graphics are controlled by a
698graphic context
699( for example the line thickness) and others are controlled through
700graphics arguments .
701%
702\begin{itemize}
703 \item {\tt xset} : to set graphic context values.
704Some examples of the use of {\tt xset} :
705
706(i)-{\tt xset("use color",flag)} changes to color or black and white plot according to
707the values (1 or 0) of {\tt flag}.
708
709(ii)-{\tt xset("window",window-number)} sets the current window to the window \\
710{\tt window-number} and creates the window if it doesn't exist.
711
712(iii)-{\tt xset("wpos",x,y)} fixes the position of the upper left point of
713the graphic window.
714
715The choice of the font, the width and height of the window, the driver...
716can be done by {\tt xset}.
717
718 \item {\tt xget} : to get informations about the current graphic context.
719All the values of the parameters fixed by {\tt xset} can be obtained by
720{\tt xget}.
721
722 \item {\tt xlfont} : to load a new family of fonts
723\end{itemize}
724%
725\subsection{Some Classical Graphics for Automatic Control}
726
727\begin{itemize}
728
729 \item \verb+bode+ : plot magnitude and phase of the
730frequency response of a linear system.
731
732 \item \verb+gainplot+ : same as bode but plots only the
733magnitude of the frequency response.
734
735 \item \verb+nyquist+ : plot of imaginary part versus real
736part of the frequency response of a linear system.
737
738 \item \verb+m_circle+ : M-circle plot used with nyquist plot.
739
740 \item \verb+chart+ : plot the Nichols'chart
741
742 \item \verb+black+ : plot the Black's diagram (Nichols'chart)
743for a linear system.
744
745 \item \verb+evans+ : plot the Evans root locus for a
746linear system.
747
748 \item \verb+plzr+ : pole-zero plot of the linear system
749
750\end{itemize}
751
752\begin{verbatim} 120\begin{verbatim}
753s=poly(0,'s'); 121-->f=gcf()
754h=syslin('c',(s^2+2*0.9*10*s+100)/(s^2+2*0.3*10.1*s+102.01));
755h1=h*syslin('c',(s^2+2*0.1*15.1*s+228.01)/(s^2+2*0.9*15*s+225));
756//bode
757subplot(2,2,1)
758gainplot([h1;h],0.01,100);
759//nyquist
760subplot(2,2,2)
761nyquist([h1;h])
762
763//chart and black
764subplot(2,2,3)
765black([h1;h],0.01,100,['h1';'h'])
766chart([-8 -6 -4],[80 120],list(1,0));
767//evans
768subplot(2,2,4)
769H=syslin('c',352*poly(-5,'s')/poly([0,0,2000,200,25,1],'s','c'));
770evans(H,100)
771\end{verbatim} 122\end{verbatim}
772 123Here {\tt f} is a handle which describes the figure properties.
773\input{figures/nouv8.tex} 124It has many fields which can be modified to change the properties
774 125of the figure.
775 126For instance, issuing
776%
777\subsection{Miscellaneous}
778%
779\begin{itemize}
780 \item \verb+edit_curv+ : interactive graphic curve editor.
781
782 \item \verb+gr_menu+ : simple interactive graphic editor. It
783is a Xfig-like simple editor with a flexible use for a nice
784presentation of graphics : the user can superpose the elements of
785\verb+gr_menu+ and use it with the usual possibilities of {\tt xset}.
786
787 \item \verb+locate+ : to get the coordinates of one or more
788points selected with the mouse on a graphic window.
789
790\end{itemize}
791%
792
793\begin{verbatim} 127\begin{verbatim}
794 128-->f.figure_name='My figure'
795\end{verbatim} 129\end{verbatim}
796\input{figures/scifi2.tex} 130will modify the \verb!figure_name! field and change the name of the
797 131figure which appears in the current graphic window.
798
799
800\section{3D Plotting}
801\subsection{Generic 3D Plotting}
802%
803\begin{itemize}
804 \item \verb+plot3d+ : 3D plotting of a matrix of points : plot3d(x,y,z) with x,y,z 3 matrices, z being the values for the points with coordinates x,y. Other
805arguments are optional
806 \item \verb+plot3d1+ : 3d plotting of a matrix of points with gray levels
807 \item \verb+fplot3d+ : 3d plotting of a surface described by a function; z is given by an external z=f(x,y)
808 \item \verb+fplot3d1+ : 3d plotting of a surface described by a function with gray levels
809\end{itemize}
810%
811
812\subsection{Specialized 3D Plotting}
813\begin{itemize}
814 \item \verb+param3d+ : plots parametric curves in 3d space
815 \item \verb+contour+ : level curves for a 3d function given by a
816matrix
817 \item \verb+grayplot10+ : gray level on a 2d plot
818 \item \verb+fcontour10+ : level curves for a 3d function given by a
819function
820 \item \verb+hist3d+ : 3d histogram
821 \item \verb+secto3d+ : conversion of a surface description from
822sector to plot3d compatible data
823 \item \verb+eval3d+ : evaluates a function on a regular grid.
824(see also feval)
825\end{itemize}
826%
827
828
829\subsection{Mixing 2D and 3D graphics}
830
831When one uses 3D plotting function, default graphic boundaries are
832fixed, but in $R^3$. If one wants to use graphic primitives
833to add informations on 3D graphics, the \verb+geom3d+ function can be
834used to convert 3D coordinates to 2D-graphics coordinates. The
835figure~ \ref{d710} illustrates this feature.
836
837%\def\exemple{d710}
838\input{figures/d7-10.vtex}
839
840\input{figures/d710.tex}
841
842
843\subsection{Sub-windows}
844%\def\exemple{d7-8}
845 132
846It is also possible to make multiple plotting in the same 133The handle {\tt f} has a field called ``children'' which is an handle
847graphic window (Figure~\ref{d7-8}). 134descrining the properties of the axes of the figure.
848
849\input{figures/d7-8.vtex}
850
851\input{figures/d7-8.tex}
852\caption{\label{d7-8}Use of subplot}
853\end{figure}
854
855
856\subsection{A Set of Figures}
857%\def\exemple{d7a11}
858
859In this next example we give a brief summary of different plotting
860functions for 2D or 3D graphics. The figure~ \ref{d7a11} is
861obtained and inserted in this document with the help of the command
862\verb+Blatexprs+.
863
864\input{figures/d7a11.vtex}
865
866\input{figures/d7a11.tex}
867\caption{\label{d7a11}Group of figures}
868\end{figure}
869
870\section{Printing and Inserting Scilab Graphics in \LaTeX}
871
872We describe here the use of programs (Unix shells) for handling Scilab
873graphics and printing the results. These programs are located in the
874sub-directory {\tt bin} of Scilab.
875
876\subsection{Window to Paper}
877The simplest command to get a paper copy of a plot is to click on the
878{\tt print} button of the ScilabGraphic window.
879
880\subsection{Creating a Postscript File}
881We have seen at the beginning of this chapter that the simplest way to get
882a Postscript file containing a Scilab plot is :
883
884\begin{verbatim}
885-->driver('Pos')
886
887-->xinit('foo.ps')
888
889-->plot3d1();
890
891-->xend()
892
893-->driver('Rec')
894
895-->plot3d1()
896
897-->xbasimp(0,'foo1.ps')
898
899\end{verbatim}
900
901
902The Postscript files ({\tt foo.ps } or {\tt foo1.ps }) generated by Scilab
903cannot be directly sent to a
904Postscript printer, they need a preamble. Therefore, printing is done
905through the use of Unix scripts or programs which are provided with
906Scilab. The program \verb+Blpr+ is used to print a set of Scilab Graphics
907on a single sheet of paper and is used as follows~:
908
909\begin{verbatim}
910 Blpr string-title file1.ps file2.ps > result
911\end{verbatim}
912
913You can then print the file {\tt result} with the classical Unix command :
914 135
136Assume now that we have plotted a graph by the
137{\tt plot2d(x,y)} command want add a title to the graph obtained.
138The handle associated with the figure is \verb!f=gcf()!.
139To access to the properties of the axes of the figure one can enter
915\begin{verbatim} 140\begin{verbatim}
916lpr -Pprinter-name result 141-->a=f.children
917\end{verbatim} 142\end{verbatim}
918 143and we see that the handle {\tt a} has a field named ``title''.
919\noindent or use the \verb+ghostview+ Postscript interpreter on your Unix 144Now if we enter
920workstation to see the result.
921
922You can avoid the file {\tt result} with a pipe, replacing {\tt > result}
923by the printing command {\tt | lpr} or the previewing command
924{\tt | ghostview -}.
925
926The best result (best sized figures) is obtained when printing two
927pictures on a single page.
928
929
930\subsection{Including a Postscript File in \LaTeX}
931
932The \verb|Blatexpr| Unix shell and the programs \verb+Batexpr2+ and
933\verb+Blatexprs+ are provided in order to help inserting Scilab graphics
934in \LaTeX .
935
936Taking the previous file {\tt foo.ps} and typing the following statement
937under a Unix shell~:
938\begin{verbatim} 145\begin{verbatim}
939Blatexpr 1.0 1.0 foo.ps 146-->l=a.title
940\end{verbatim} 147\end{verbatim}
941creates two files \verb+foo.epsf+ and \verb+foo.tex+. The original 148we see that {\tt l} is itself a handle with a field named ``text''.
942Postscript file is left unchanged. 149We can give a title to the plot by the command \verb!l.text=My plot'!
943To include the figure in a \LaTeX~ document you should insert the following 150Of course it is possible to obtain the same result by
944\LaTeX~ code in your \LaTeX~ document~: 151the command
945
946\begin{verbatim} 152\begin{verbatim}
947\input foo.tex 153f.children.title.text='My plot'
948\dessin{The caption of your picture}{The-label}
949\end{verbatim} 154\end{verbatim}
155This simple example illustrates how to manipulate graphics within Scilab.
950 156
951You can also see your figure by using the Postscript 157\section{Graphic objects properties}
952previewer \verb+ghostview+. 158Help on the graphics objects can obtained by the command
953
954The program \verb+Blatexprs+ does the same thing: it is used to insert
955a set of Postscript figures in one \LaTeX picture.
956
957In the following example, we begin by using the Postscript driver {\tt Pos}
958and then initialize successively 4 Postscript files
959{\tt fig1.ps, ..., fig4.ps} for
9604 different plots and at the end return to the driver {\tt Rec} (X11 driver
961with record).
962
963\input{diary/mulplot.dia}
964
965Then we execute the command :
966
967\begin{verbatim} 159\begin{verbatim}
968 Blatexprs multi fig1.ps fig2.ps fig3.ps fig4.ps 160-->help graphics_entities
969\end{verbatim} 161\end{verbatim}
970 162The properties of the various graphic objects are obtained by the command
971\noindent and we get 2 files {\tt multi.tex} and {\tt multi.ps} and you can
972include the result in a \LaTeX~ source file by :
973
974\begin{verbatim} 163\begin{verbatim}
975\input multi.tex 164-->help object_properties
976\dessin{The caption of your picture}{The-label}
977\end{verbatim} 165\end{verbatim}
166where {\verb!object_properties!} is in the following table.
167\begin{center}
168\begin{tabular}{|c|}
169\hline
170{\verb!agregation_properties!} \\ \hline
171{\verb!arc_properties!} \\ \hline
172{\verb!axes_properties!} \\ \hline
173{\verb!axis_properties! } \\ \hline
174{\verb!champ_properties! } \\ \hline
175{\verb!fec_properties!} \\
176{\verb!figure_properties!} \\ \hline
177{\verb!grayplot_properties!} \\ \hline
178{\verb!label_properties! } \\ \hline
179{\verb!legend_properties! } \\ \hline
180{\verb!param3d_properties !} \\ \hline
181{\verb!polyline_properties! } \\ \hline
182{\verb!rectangle_properties !} \\ \hline
183{\verb!segs_properties! } \\ \hline
184{\verb!text_properties! } \\ \hline
185{\verb!title_properties! } \\ \hline
186\end{tabular}
187\end{center}
188
189To get a handle associated with a graphic object, one can use the
190functions {\tt gcf()} (current Figure), {\tt gca()} (current Axes),
191or {\tt gce()} (current Entity). From the top figure handle, one
192can access the complete tree of (sub)handles by selecting the various
193children and parents of a given handle.
194
195\section{Some useful plotting functions}
196\subsection{2D plots}
197\begin{center}
198\begin{tabular}{|c|c|}
199\hline
200{\tt plot2d } & basic plot function \\ \hline
201{\tt plot3d } & plot surface \\ \hline
202{\tt param3d } & parametric plot \\ \hline
203{\tt (f)champ} & vector field plot \\ \hline
204{\tt contour}, {\tt fcontour}, {\tt (f)contour2d}, \\
205{\tt contourf}, {\tt fcontour2d} & level curve plot \\ \hline
206{\tt errbar } & add error bar \\ \hline
207{\tt Matplot } & 2D plot of a matrix using colors \\ \hline
208{\tt histplot} & histogram \\ \hline
209{\tt errbar} & vertical bars \\ \hline
210{\tt S(f)grayplot} & smooth 2D plot of surface \\ \hline
211{\tt (f)grayplot} & 2D plot of surface \\ \hline
212\end{tabular}
213\end{center}
214
215\subsection{3D plots}
216\begin{center}
217\begin{tabular}{|c|c|}
218\hline
219{\tt (f)plot3d } & plot surface \\ \hline
220{\tt param3d(1) } & parametric plot \\ \hline
221{\tt contour} & level curve plot \\ \hline
222{\tt hist3d} & 3D histogram\\ \hline
223{\tt genfac3d, eval3dp } & compute factes \\ \hline
224{\tt hist3d} & histogram \\ \hline
225{\tt geom3d} & 3D projection \\ \hline
226{\tt S(f)grayplot} & smooth 2D plot of surface \\ \hline
227{\tt (f)grayplot} & 2D plot of surface \\ \hline
228\end{tabular}
229\end{center}
230
231\subsection{Low level 2D plots}
232\begin{center}
233\begin{tabular}{|c|c|}
234\hline
235{\tt xpoly} & polyline plot \\ \hline
236{\tt xpolys } & multi-polyline plot \\ \hline
237{\tt xrpoly} & regular polygon plot \\ \hline
238{\tt xsegs} & draw unconnected segments\\ \hline
239{\tt xfpoly(s) } & filled polygon(s) \\ \hline
240{\tt xrect } & rectangle plot \\ \hline
241{\tt xfrect } & filled rectangle plot \\ \hline
242{\tt xrects } & draw or fill rectangles \\ \hline
243\end{tabular}
244\end{center}
245
246\subsection{Strings, ...}
247\begin{center}
248\begin{tabular}{|c|c|}
249\hline
250{\tt xstring, xstringl, xstringb} & string plots \\ \hline
251{\tt xarrows} & arrows plot \\ \hline
252{\tt xarc(s), xfarc, xfarcs} & arcs plot \\ \hline
253\end{tabular}
254\end{center}
255
256\subsection{Colors}
257\begin{center}
258\begin{tabular}{|c|c|}
259\hline
260{\tt colormap} & set colormap \\ \hline
261{\tt getcolor} & select color \\ \hline
262{\tt addcolor} & add color to colormap \\ \hline
263{\tt graycolormap} & gray colormap \\ \hline
264{\tt hotcolormap} & red to yellow colormap \\ \hline
265\end{tabular}
266\end{center}
267
268\subsection{Mouse position}
269\begin{center}
270\begin{tabular}{|c|c|}
271\hline
272{\tt xclick} & wait for a mouse click \\ \hline
273{\tt locate } & mouse selection of a set of points \\ \hline
274{\tt xgetmouse} & add color to colormap \\ \hline
275{\tt graycolormap} & get the current position of the mouse\\ \hline
276\end{tabular}
277\end{center}
978 278
979Note that the second line {\tt dessin...} is absolutely necessary and you 279\section{Animated plot}\label{Animation}
980have of course to give the absolute path for the input file if you are 280\index{animated plot}
981working in another directory (see below). The file {\tt multi.tex} is only 281\subsection{pixmap mode}
982the definition of the command {\tt dessin} with 2 parameters : the caption 282To run the pixmap mode, get the handle of the current figure
983and the label; the command {\tt dessin} can be used with one or two 283\verb!f=gcf();! and activate the pixmap mode \verb!f.pixmap='on'!.
984empty arguments {\tt `` ``} if you want to avoid the caption or the label.
985 284
986The Postscipt files are inserted in \LaTeX~ with the help of the 285When the pixmap mode is on, the pixels of the graphic window
987\verb+\special+ command and with a syntax that works with the 286are stored into a temporary buffer which is displayed upon request.
988\verb+dvips+ program. 287The various steps corresponding to the creation of the image are not
288displayed.
989 289
990The program \verb+Blatexpr2+ is used when you want two pictures side 290An animated plot using this mode is generally obtained by a
991by side. 291a for or while loop which produces a new image at each iteration.
992\begin{verbatim}
993 Blatexpr2 Fileres file1.ps file2.ps
994\end{verbatim}
995 292
996%\def\exemple{d7-12} 293When the image is ready, the screen display is realized by
997\input{figures/d7-12.tex} 294the \scifun{show\_pixmap()} command.
998\caption{\label{d7-12}Blatexp2 Example}
999%\dessin{Blatexpr2 Example}{d7-12}
1000\end{figure}
1001 295
1002It is sometimes convenient to have a main \LaTeX~ document in a directory 296In the animation mode, it is often necessary to set a frame
1003and to store all the figures in a subdirectory. The proper way to 297with given dimensions in which the animated plotting command will take place.
1004insert a picture file in the main document, when the picture
1005is stored in the subdirectory \verb+figures+, is the following~:
1006 298
299To fix an appropriate frame with extremal values
300\scilab{rect=[xmin,ymin,xmax,ymax]} one can set properties of the axes
301(\verb!data_bounds! field obtained by \verb!gca()!) or alternaltively
302enter the command
303\noindent
1007\begin{verbatim} 304\begin{verbatim}
1008\def\Figdir{figures/} % My figures are in the {\tt figures/ } subdirectory. 305plot2d([],[],rect=[xmin,ymin,xmax,ymax]).
1009\input{figures/fig.tex}
1010\dessin{The caption of you picture}{The-label}
1011\end{verbatim} 306\end{verbatim}
1012 307
1013The declaration \verb+\def\Figdir{figures/}+ is used twice, first to 308Assume that \scilab{y=phi(x,t)} is a vector with the same
1014find the file {\tt fig.tex} (when you use \verb+latex+), and 309dimension as \scilab{x}
1015 second to produce a correct pathname for the 310and depending on the parameter \scilab{t}. The animated graph of \scilab{y}
1016\verb+special+ \LaTeX~ command found in \verb+fig.tex+. (used at 311as a function of \scilab{t} (for a fixed \scilab{x} vector), is seen by
1017dvips level). 312the following code~:
1018
1019-WARNING : the default driver is {\tt Rec}, i.e. all the graphic commands are
1020recorded, one record corresponding to one window. The {\tt xbasc()} command
1021erases the plot on the active window and all the records corresponding to
1022this window. The {\tt clear} button has the same effect; the {\tt xclear}
1023command erases the plot but the record is preserved. So you almost never need
1024to use the {\tt xbasc()} or {\tt clear} commands. If you use such a command
1025and if you re-do a plot you may have a surprising result (if you forget
1026that the environment is wiped out); the scale only is preserved and so you
1027may have the ``window-plot'' and the ``paper-plot'' completely different.
1028
1029
1030\subsection{Postscript by Using Xfig}
1031
1032Another useful way to get a Postscript file for a plot is to use Xfig.
1033By the simple command {\tt xs2fig(active-window-number,file-name)} you get
1034a file in Xfig syntax.
1035
1036This command needs the use of the driver {\tt Rec}.
1037
1038The window ScilabGraphic0 being active, if you enter :
1039
1040\begin{verbatim} 313\begin{verbatim}
1041 314f.pixmap='on'; //The data is sent into a pixmap
1042-->t=-%pi:0.3:%pi; 315plot2d(x,phi(x,theta(1))); //First y for t=theta(1)
1043 316w=gce(); //The current entity
1044-->plot3d1(t,t,sin(t)'*cos(t),theta=35,alpha=45,flag=[2,2,4]); 317for t=theta
1045 318 w.children.data(:,2)=phi(x,t)'; //update y
1046-->xs2fig(0,'demo.fig'); 319 show_pixmap(); //display the pixmap content
1047 320end
1048\end{verbatim} 321\end{verbatim}
322The role of pixmap mode is to avoid image blinking. Any modification
323of a graphic property implies a complete display of the new graph
324(including axes, titles etc). In the pixmap mode the new image is
325built and displayed afterwards by the \scifun{show\_pixmap()} command.
1049 326
1050you get the file {\tt demo.fig} which contains the plot 327Function \scifun{xpause} can be used to slow down the graphic display.
1051of window 0.
1052
1053Then you can use Xfig and after the modifications you want, get a Postscript
1054file that you can insert in a \LaTeX~ file. The following figure is the result
1055of Xfig after adding some comments.
1056
1057\begin{figure}
1058%BEGIN IMAGE
1059\fbox{\hspace*{0.cm} \begin{picture}(400.0,350.0)(100.0,200.0)
1060\hspace{-0.8cm}
1061\special{psfile=figures/demo.ps}
1062\end{picture}}
1063%END IMAGE
1064%HEVEA\imageflush
1065
1066\caption{Encapsulated Postscript by Using Xfig}
1067\label{xfig2ps}
1068\end{figure}
1069
1070
1071\subsection{Encapsulated Postscript Files}
1072As it was said before, the use of {\tt Blatexpr} creates 2 files : a
1073{\tt .tex} file to be inserted in the \LaTeX~ file and a {\tt .epsf} file.
1074
1075It is possible to get the encapsulated Postscript file corresponding to a
1076{\tt .ps} file by using the command {\tt BEpsf}.
1077 328
1078Notice that the {\tt .epsf} file generated by {\tt Blatexpr} is not an 329%\end{center}
1079encapsulated Postscript file : it has no bounding box and {\tt BEpsf}
1080generates a {\tt .eps} file which is an encapsulated Postscript file with
1081a bounding box.
diff --git a/scilab_doc/intro/intro.tex b/scilab_doc/intro/intro.tex
index fb6ae9d..0fd05c7 100755
--- a/scilab_doc/intro/intro.tex
+++ b/scilab_doc/intro/intro.tex
@@ -1,25 +1,28 @@
1% Copyright INRIA
2
3\documentclass[11pt]{report} 1\documentclass[11pt]{report}
4 2
5\usepackage{makeidx} 3\usepackage{scilab}
6 \textheight=660pt
7 \textwidth=15cm
8 \topmargin=-27pt
9 \oddsidemargin=0.7cm
10 \evensidemargin=0.7cm
11 \marginparwidth=60pt
12 4
5\usepackage{amsmath,amssymb,times,subfigure,epsfig,fancyheadings,verbatim,moreverb,makeidx}
6\usepackage{hyperref}
7\usepackage[T1]{fontenc}
13\def\Figdir{figures/} 8\def\Figdir{figures/}
14 9
15\makeindex 10\makeindex
11 \textheight=21cm
12 % \textwidth=15cm
13 \textwidth=15cm
14 % \topmargin=-27pt
15 \oddsidemargin=0.7cm
16 \evensidemargin=0.7cm
17 % \marginparwidth=60pt
18
16 19
17\begin{document} 20\begin{document}
18 21
19\include{chap0} 22\include{chap0}
20 23
21\pagenumbering{roman} 24\pagenumbering{roman}
22\tableofcontents 25%\tableofcontents
23\pagestyle{headings} 26\pagestyle{headings}
24\pagenumbering{arabic} 27\pagenumbering{arabic}
25 28
@@ -35,8 +38,6 @@
35 38
36\include{chap6} %interfacing 39\include{chap6} %interfacing
37 40
38%\include{appendices}
39
40\listoffigures 41\listoffigures
41 42
42\printindex 43\printindex