Ian Searle
The title says it quite succinctly. The purpose of this article is to explain why you might want to use RLaB as opposed to Matlab. This purpose of this article is not to belittle Matlab instead, I will try and point out the differences between the two programs, and consequently why you may, or may not, want to use RLaB. I have organized this article into three sections. The first is an attempt to discuss the similarities present in the two programs. The second section is an attempt to present a strictly technical argument. While the third section is left for everything else.
I would like this article to be as objective as possible,
even considering who it is written by. If you feel that I have
unfairly criticized Matlab or drawn invalid comparisons, please feel
free to write me at ians@eskimo.com
to express your opinions.
Both programs are Very High Level languages (VHLL) oriented towards applied mathematics. As languages, both offer numerical and string variables and arrays, conditional and flow-control constructs, and functions. Both programs offer an interface to the more popular linear algebra functions available through Netlib1. Both programs offer convenient visualization of data through two and three dimensional plotting functions.
As VHLL with convenient data visualization, both programs offer an environment for numerical computation, experimentation, and algorithm development that is generally more productive that the traditional develop--compile--link--run--debug cycle we are all familiar with.
Now I will attempt to point out the technical differences between the two programs.
RLaB offers more than the matrix as a data type. However, the matrix is probably the most often used data structure. Like Matlab, RLaB's matrices are used to represent scalars, vectors, and matrices, both real and complex. At this point in time RLaBdoes not offer a sparse matrix.
In addition to the matrix, RLaB has a string class, and data type. A string is a variable length collection of characters. Both string vectors, and string matrices are supported. One advantage to the addition of this type is the ability to collect strings of different lengths in the same vector or matrix.
However, the most significant improvement is RLaB's list class. A list is a heterogeneous associative array that can contain any data type, including other lists. The list gives RLaBusers the opportunity to structure their data as necessary. Some possible uses are:
for (i in 1:N) { ldata.[i] = readm ("datafile." + num2str (i)); }
Now the list, ldata
can be passed to a function
for processing: process_data (ldata)
.
ss1 = ss_create ( freqv, dampv ) // Create a state-space model // from frequencies and damping. ss1.bode = ss_bode ( ss1, IN, JW ) // Compute Bode plot for state-space // model.
In these situations the list helps the user/programmer organize the data in sensible ways that can reduce confusion.
In this example we will read a data-file that contains some test output. The engineer doing the test annotated each row of test output with a label. We would like to maintain the label, and use it from within RLaB. The file looks like:
sensor1 0.162 0.665 0.0847 0.204 0.167 sensor2 0.655 0.129 0.91 control 0.112 0.299 0.265 0.7
We can read this data, and maintain the strings as labels by:
> while (length (line = getline ("test.data"))) { test_data.[line.[1]] = get_test_vector (line); } > test_data test_data = control sensor1 sensor2 > test_data.sensor1 sensor1 = 0.162 0.665 0.0847 0.204 0.167
As you can see, the data is now stored in a list, with
element names from the first field of
test.data
. Each element is a numeric vector,
which contains the rest of the data in each
row. get_test_vector
is a simple nine-line
function that returns all but the first element as a
vector.
In RLaB, we try to overcome these limitations with the following:
fprintf
can be used to send
commands or data to a process
fprintf ("| gnuplot", "plot %s using 1:3\n", tmp_file_name);
Or readm
can be used to read the output of a filter on
some pre-existing data.
x = readm ("| awk -f data_filter.awk < orig_data");
In RLaB expressions usually (most always) have a result. You can figure out for yourself what the result of a particular statement will be by evaluating each sub-expression, starting at the lowest level, and combining the results, until you have the answer. Sometimes this is called a substitution model of evaluation. When using RLaB there should be less idiosyncrasies to deal with.
RLaB offers a much simpler data visualization capability. RLaB graphics are handled through a scientific graphics library called Plplot. The Plplot API is implemented as a set of builtin functions within RLaB. Thus, the high level plotting capabilities are handled by RLaB programs. Two and three dimensional plots, contours, and histograms, with a host of options are supplied. Custom plots are can be created by utilizing the low-level Plplot API. The most popular output devices (screens and printers) are supported. When using X-windows, there is a nice ``plot-widget'' that allows the user to zoom and pan, print plots, and tweak the color-maps.
If you need really ``gee--whiz--turbo--object--oriented'' graphics, you ought to be looking at Matlab. If you need a good programming language that offers good data visualization, then RLaB deserves a look.
RLaB's linear algebra functions are mostly supplied by the
source code from the LAPACK project. LAPACK could be called
``LINPACK +
EISPACK Edition''. The LAPACK
functions offer some block structured algorithms, and utilize
levels 2 and 3 BLAS. Thus, on some machines they may provide
better performance.
RLaBis available in binary and source-code formats. Since you can get the source code, you can port it to any platform you like. There are no charges for using RLaB. You can get free support from the RLaBuser's group, and the author. If you want more reliable support, you can pay someone (usually a consultant).
Some would feel that RLaBis better as a long term tool, since they have the source code and can run the program on most any computer without restriction. Others would feel that since Matlab is commercially supported/developed that it is more reliable as a long term tool.
RLaBdoes not offer the same selection of toolboxes, either commercial or contributed. There is a growing number of contributed rfiles, and a controls, testmatrix, and signal-processing collections are in the works. But RLaB will never match Matlab's volume of toolbox material. If you are a student or in the position of writing most of your own procedures, then this may not matter much to you.
There is no way to summarize exept to say: decide for yourself. The choice is not simple, and it is worth careful consideration, since both programs can have a significant impact upon the way you do your work/learning.
This document was generated using the LaTeX2HTML translator Version 99.2beta6 (1.42)
Copyright © 1993, 1994, 1995, 1996,
Nikos Drakos,
Computer Based Learning Unit, University of Leeds.
Copyright © 1997, 1998, 1999,
Ross Moore,
Mathematics Department, Macquarie University, Sydney.
The command line arguments were:
latex2html -no_navigation -split 0 rlab-why
The translation was initiated by Ian R. Searle on 2000-01-09