Scilab, Another Free Math Alternative
Scilab is matrix oriented math language made freely available for both Linux
and Microsoft Windows users. It is not open source, and thus has a few more
user restrictions than a purely open source statistics language like R.
However the user license is liberal in its allowances.
This web page offers a glimpse into the use of Scilab and compares it
to other common matrix languages available in Linux. If you need a definitive
guide to using Scilab, check out Engineering and Scientific Computing with Scilab.
Above you see a plot of the sinx/x function as made with the
Scilab mesh command. This is the default mesh plot produced by
Scilab, without using any of the available enhancements.
Scilab was created and is maintained by INRIA, the French National
Institute for Research in Computer Science and Control. By going to scilab.org you can read about Scilab and
obtain the latest version. The version I'm reviewing here came packaged
with my Etch Debian distribution.
Scilab has a GUI interface even in the Linux version, unlike many of the
Linux math languages like Octave, R, and Yorick. The interface is not
elaborate, but does give handy access to some file functions and help
Syntactically, Scilab is similar to, but not identical to MATLAB and Octave.
Like MATLAB and Octave, Scilab works primarily with 2 dimensional matrices, and
like Octave and MATLAB it assumes operations are to be matrix operations. That
is, you need to use modified operators if you want scalar operations. For
example, the expression:
z = x * y
performs the full matrix multiply of x times y. If you wish to only do a
cell by cell multiplication of the respective x cells and y cells, a
modified multiply operator must be used as in the following example:
z = x .* y
The .* operator specifies a scalar operation. The dot modification
is also applied to other math operators to indicate a scalar operation
In addition to the matrix data structure, Scilab supports a higher level
structure similar to the C-like struct data structure. In this way one can
package together different data types under one label. These higher level
structures themselves can be kept in arrays, making an array of data
Math operations cannot be performed on these higher level structures, but
can be performed on the individual elements of the structure, such as on
a matrix that might be one of the elements. For example, you can
create an x variable that has more than one conceptual element. In the
following case, an x variable is created that has a, b, and c elements. The a
element is a 3x3 matrix, the b element is a scalar, and the c element is a 3x2
x.a = [1,2,3;11,12,13;21,22,23];
x.b = 10;
x.c = [100,102;200,202;300,302];
The a portion of the structure can be addressed by x.a, and
so on. If y is and array of these structures, the addressing would be
z = y(i).a, where i is the desired index of the high level y
Scilab is not a clone of
MATLAB. It is similar in function and syntax, but certainly not exactly
the same. If you're really wanting an alternative that has a closer syntax
to MATLAB, then I suggest you consider Octave.
None-the-less, Scilab matrix nomenclature and I/O are quite similar to
MATLAB so users could make the transition fairly easily. Logic structures are
an example of the nature of the differences between the languages. In Scilab, a
simple end statement marks the end of most logic constructs, like
for statements and if statements.
One of the main differences is that with Scilab, user function files must be
loaded with a getf command before they can be used, rather than
auto-loaded on reference as in MATLAB and Octave. It's common to store several
functions in a single file, making the file more of a library of functions.
Thus a single getf command can load a number of related functions all at
Scilab also uses the varargin array method of passing a variable
number of arguments to user-defined functions. And as with Octave, some logic
must be generated by the user to handle whether function variables have default
values, or are passed values embedded in varargin.
Packages and I/O
Scilab has a large collection of engineering oriented packages covering
signal processing, linear algebra, filtering, sound file handling, and a number
of statistics functions. Scilab comes complete with a pretty handy GUI
interface in Linux and in Windows.
Scilab provides simple commands for saving and loading matrices in a Scilab
native form. It also has commands for loading and saving MATLAB compatible
files. Scilab can even load xls spreadsheet files. Also provided are some
primitive I/O commands that give Scilab users the ability to read and write
most file formats they might need, providing they have documentation on the
Included with Scilab is a GUI programming utility called scicos. With
scicos, one can drag icons of different math functions onto a graphical window,
edit them to set parameters or describe functions, connect them into a desired
logical sequence, and then initiate the process that will run the graphically
Help is available in Scilab through the GUI as a pull down menu, or one can
type help topic and help of the topic will pop up in a window. Once help
is initiated, it can be navigated by using the mouse.
Scilab has a very robust integrated graphics package, supporting the
making of all manner of line plots, contours, color contours, and surface
maps. Above you see a line contour map made by Scilab.
The labeling and annotations of the axes can be controlled, the number
of contours can be selected, and various other aspects of the presentation
can also be controlled. Contours of large matrices are created fairly
As the above image illustrates, Scilab can also be configured to display
color filled contours. The user can use the colormap utility to set any
desired colormap for presentation.
Scilab can also render images, such as a digital camera image. However I was
unable to find an image loader for Scilab. Apparently if one wants to load an
image into Scilab for processing in some way, the image must be turned into one
of the binary or ASCII matrix forms that Scilab can handle.
I used a pdl script to convert an image into a format that Scilab could
load. I found that Scilab wasn't very fast at rendering images that were
perhaps 300 x 300 or so in size. Scilab can, however, export a graph in a few
standard graphics formats. It can export a graph as a GIF file, a postscript
(ps) file, or a PPM file.
The image above is another mesh, but with an added z-axis
correlated color map. User selected or generated color maps are used for
both contour and 3D images.
Scilab does provide the user the ability to interact with a graph. Commands
are available for obtaining the location of the mouse within a graph, and for
obtaining mouse button information. One can, for example, use the Scilab rubber
band box to select a section of a plot.
Scilab is a very powerful, well documented scripting language that contains
a large library of signal processing routines. For general mathematical data
processing, statistical analysis, and modeling exercises, Scilab makes a great
tool. If users are familiar with MATLAB, they should be able to adjust to
Scilab quickly. Given the limitations of image reading routines and the
slowness of Scilab to render large images, I would think that Scilab isn't the
first choice for for image processing.
I list below my subjective thoughts on the Scilab Matrix Language.
Freely available for the MacOS, Linux, and Windows operating systems.
Uses a familiar syntax, much like Octave, though it doesn't use the auto loaded m file library design.
Has integrated 2D and 3D graphic routines, mouse clicks can return information to the program scripts.
Processes matrices as quickly as most any other matrix language.
Has enough C style file I/O routines to allow file compatibility
with external utilities.
Has extensive libraries for support of problems involving: Linear Algebra,
System and Control, Signal Processing, Simulation, and more.
Has a GUI interface for controlling the environment and accessing the
Has a robust string manipulation library.
Can work with matrices with greater than 2 dimensions.
Can support a data record nomenclature.
Has an optional symbolic programming interface (SCICOS)
Slows down considerably if loops are used extensively.
The GUI interface can get into the way.
Designed to be primarily used interactively. Not as easily used in
Has no graphic input file capability, and limited graphic file output