Matlab 版 (精华区)
发信人: zhili (北侠), 信区: Matlab
标 题: Comparison of Matlab 4.2 with Scilab 2.3
发信站: 紫 丁 香 (Fri Nov 13 11:39:03 1998), 转信
Subject: Comparison of Matlab 4.2 with Scilab 2.3
Author: Carey Bunks <cbunks@requin.bbn.com>
Organization: BBN Planet
Date: 20 Jun 1997 15:45:20 -0400
I've seen several postings in comp.soft-sys.matlab posing questions on the
relative merits of Scilab and Matlab (as well as Octave and Rlab). I've
had quite a bit of experience with both Scilab and Matlab and the following
is a list of things that come to my mind in making a comparison between the
two (NB: this is neither an exhaustive nor authoritative list.
Furthermore, this discussion has to be revisited for Matlab 5 with which
I'm mostly unfamiliar).
===========================================================================
An In Depth and Probably Incomplete Comparison of Scilab 2.3 and Matlab 4.2
===========================================================================
In what follows I try to address three questions: 1) What are the merits
and demerits of the relative functionality between Matlab and Scilab, 2)
How transportable is code from one to the other, and 3) What is the ease
of use (human factors) of each.
---------------------------------------------------------------------------
Syntax
---------------------------------------------------------------------------
The syntax of Matlab and Scilab are identical for most operations.
Matrix-vector products, extraction and insertion of submatrices, complex
variables, functions calls, etc. are all the same. Syntactically there is
one feature in Scilab which does not exist in Matlab: the end of sequence
symbol $. This symbol allows one to extract the last element of a
vector/matrix without knowing its length. For example in Matlab
>> x=rand(1,5)
x =
0.3834 0.0668 0.4175 0.6868 0.5890
>> x(3:length(x))
ans =
0.4175 0.6868 0.5890
and in Scilab
-->x=rand(1,5)
x =
! .3126 .3616 .2922 .5664 .4826 !
-->x(3:$)
ans =
! .2922 .5664 .4826 !
---------------------------------------------------------------------------
Primitive Operations
---------------------------------------------------------------------------
The operations, + - * / ^ and the dot operations .* ./ .^
are identical in both Matlab and Scilab. Scilab has an additional
operation called the Kronecker product (division) which is formed
with the .*. and ./. operations.
---------------------------------------------------------------------------
Data Types
---------------------------------------------------------------------------
Both Matlab and Scilab have both real and complex scalars, vectors,
matrices as well as strings. Scilab's handling of strings is more
flexible that Matlab's. For example Matlab cannot form a matrix of
variable length strings whereas Scilab can. Furthermore, Scilab has
several data types which do not exist in Matlab. These are
polynomials, lists, typed lists, sparse matrices, and booleans.
Furthermore, both compiled and uncompiled functions are types in
Scilab and can be manipulated as data. I find this to be an extremely
powerful feature of Scilab.
---------------------------------------------------------------------------
Function Names
---------------------------------------------------------------------------
Most function names such as "log", "cos", "atan", etc. are identical
in Matlab and Scilab. There are some notable differences, however,
such as the function "reshape" in Matlab which is called "matrix" in
Scilab. Furthermore, less ordinary functions have different calling
arguments. An example of this is "fft" and "ifft" in Matlab:
xf = fft(x);
x = ifft(xf);
In Scilab these calls would be made by:
xf = fft(x,-1);
x = fft(x,1);
In any port of code from Matlab to Scilab or vice versa will have to
make a full accounting of these function call differences.
---------------------------------------------------------------------------
Special Constants
---------------------------------------------------------------------------
Matlab has some special constants such is "i", "pi", "inf", and "nan".
In Scilab these special constants are represented by "%i", "%pi",
"%inf", and "%nan". Other special constants in Scilab are the
booleans "%t" and "%f", "%e", the machine precision "%eps", and two
symbolic polynomial constants "%s" and "%z".
---------------------------------------------------------------------------
Plotting
---------------------------------------------------------------------------
Scilab has very powerful plotting capabilities which rival those of
Matlab. Matlab's plotting interface, however, is much bettor
conceived than Scilab's. Matlab's calls to plot functions are easy to
use and the graphic handles make for a plotting environment which
takes the work out of making plots come out the right way. Scilab,
unfortunately, has plot functions whose use are not at all
transparent. I've always been able to create similar plots in Matlab
and Scilab but it is easier in Matlab. This is an area in which I
think Scilab needs to progress further and since it is an open system
(source code is completely available) it is possible that this may
come from the user community...
---------------------------------------------------------------------------
Graphical User Interfacing
---------------------------------------------------------------------------
Both Matlab and Scilab allow simple programming of graphical user
interfaces. In my opinio Matlab's GUIs are nicer looking than
Scilab's.
---------------------------------------------------------------------------
Toolboxes
---------------------------------------------------------------------------
Matlab can come with a very large number of toolboxes. The toolboxes
are collections of functions geared to specialized domains and the
current list of Matlab supported toolboxes is:
Chemometrics
Communications
Control System
Financial Toolbox
Frequency Domain System Identification
Fuzzy Logic
Higher-Order Spectral Analysis
Image Processing
LMI Control
Mapping
Model Predictive Control
?Analysis and Synthesis
NAG
Neural Network
Optimization
Partial Differential Equation
QFT Control Design
Robust Control
Signal Processing
Spline
Statistics
System Identification
Symbolic/Extended Symbolic Math
Wavelet
Although Scilab does not have as many toolboxes as Matlab it
does have a good selection of which there are:
Linear Algebra
ARMA
Classical Control
Polynomial Toolbox
Communications
Tree and Graph (Metanet)
Nonlinear Optimization and Simulation
Robust Control
Signal Processing
Hidden Markov Models
---------------------------------------------------------------------------
Graphical Simulation
---------------------------------------------------------------------------
For graphical simulation Matlab has Simulink and Scilab has Scicos.
---------------------------------------------------------------------------
Online Help
---------------------------------------------------------------------------
Scilab has a great online help GUI. Getting online help can be
obtained by keyword and always appears in a separate window. This is
very helpful when one wants to read the help and type commands at the
same time. Unfortunately, much of the help needs to go through an
edit cycle since it is sometimes a little cryptic and not always in
clear English.
---------------------------------------------------------------------------
Lists
---------------------------------------------------------------------------
One of the major advantages that Scilab has over Matlab is the list
data type. This allows the grouping of unlike data types into a
single object which in turn allows for data abstraction (see next
heading). As an example:
-->L = list([1 2 3],'Scilab',%s^2+1)
L =
L(1)
! 1. 2. 3. !
L(2)
Scilab
L(3)
2
1 + s
Extraction and insertion are available at any level so that
-->L(1)(3)
ans =
3.
yields the third element of the first element of the list.
(NB: Matlab 5 allows some sort of data structure which is like
a list but I'm not familiar with the details)
---------------------------------------------------------------------------
Data Abstraction and Operator overloading
---------------------------------------------------------------------------
One of the most powerful aspects of Scilab is it's ability to easily
perform data abstraction and operator overloading. Scilab is
delivered with several pre-defined abstract data types such as
rational polynomials and linear systems. Overloading of the usual
operators such as "+", "-", "*", "/", and "=" allows the user to
easily manipulate these abstract data types and the development of
higher level operations is greatly simplified. Here is an example
with two rationals:
--> r1=(2+3*s)/(1+s**2)
r1 =
2 + 3s
-------
2
1 + s
--> r2=s/(5+s)
r2 =
s
------
5 + s
--> r3=r1+r2
r3 =
2 3
10 + 18s + 3s + s
------------------
2 3
5 + s + 5s + s
Notice that even though the rationals in the example are lists the
overloading of the "=" operator gives rise to a user friendly
on-screen representation which is recognizabe as that of a rational.
Furthermore since the "+" operator is overloaded for rationals their
sum is defined and requires no special function (like
r3=poly_add(r1,r2) as an example). The implementation of the rational
abstract data type in Scilab allows all the usual operations that one
would expect between two rationals as well as between a rational and
other data types (such as scalars and matrices).
The user of Scilab can easily define new abstract data types and
develop Scilab macros for the implementation of user transparent
operator overloading.
---------------------------------------------------------------------------
Access to Unix and File Handling
---------------------------------------------------------------------------
Both Matlab and Scilab have file reading and writing functions so that
data can be exploited in numerical computations. Furthermore, Scilab
can read and write Matlab .mat files which is useful if one is
cooperating with a colleague who uses Matlab.
Matlab has a couple of features which makes accessing and executing of
data and scripts which I find a little more convenient than Scilab.
In particular the execution of a Matlab script can be performed just
by typing it's name. Furthermore, Matlab has a pathname variable
which can be set and which defines what directories to search for a
script file. Scilab's approach is different in that scripts can be
executed and functions can be imported into Scilab either directly on
the Scilab command line or through a pull down menu in the Scilab GUI
window.
---------------------------------------------------------------------------
Memory Allocation
---------------------------------------------------------------------------
Matlab dynamically allocates memory whereas Scilab statically
allocates memory. Although Scilab allows the expansion of its
internal memory stack (with the command "stacksize") to the limit of
RAM + swap I've found that in my personal use of Matlab and Scilab
that Matlab handles memory needs for memory intensive applications a
little bettor than does Scilab.
---------------------------------------------------------------------------
Bugs
---------------------------------------------------------------------------
Matlab is a more finished product and I've found very few problems
working with version 4.2 (this may not be the case with version 5).
Scilab still has plenty of small bugs and, occasionally, will blow a
valve. I fully expect, though, that, as is the case for Linux, that
since the source code for Scilab is open to the public under the GNU
general license that it will quickly be improved on not only by the
Scilab group but by the internet community at well.
------------------------------------
Dr. Carey Bunks
Senior Scientist
BBN Corp.
70 Fawcett St, 15/2A
Cambridge, MA 02138
tel: 617-873-3028 fax: 617-873-2918
email: cbunks@bbn.com
------------------------------------
--------------------------------------------------------------------------------
The Math Forum
--
※ 来源:.紫 丁 香 bbs.hit.edu.cn.[FROM: cal.hit.edu.cn]
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:207.275毫秒