Article View: sci.math.num-analysis
Article #1151Re: Octave -- a high-level language for numerical computations
From: John W. Eaton
Date: Tue, 12 Jan 1993 09:29
Date: Tue, 12 Jan 1993 09:29
77 lines
2843 bytes
2843 bytes
In article <AJT.93Jan12171438@peregrin.resmel.bhp.com.au>
ajt@resmel.bhp.com.au (Andrew Telford) writes:
> Are there any significant differences between Octave and the MATLAB
> clone RLab which is also under the GPL and in alpha test:
RLaB is definitely not a Matlab clone -- the syntax of the RLaB
language is very different from the syntax of Matlab. The README file
that comes with RLaB even says:
RLaB is NOT a MATLAB clone!
Because of this, there may be more differences between Octave and RLaB
than there are similarities. For example, FOR loops in Octave may be
written as
for i = 1:4
for j = 1:5
m(i,j) = i+j;
end % one may also use `endfor' here, which can help
end % debugging of mismatched `end' statements
but in RLaB the above would (I think) be written as
for(i in 1:4) {
for(j in 1:5) {
m[i;j] = i+j;
}
}
Note also that RLaB uses square brackets instead of parenthesis for
matrix indexing, and semicolons instead of commas to separate the
indices.
Function definitions are also much different. Octave allows
function [x, y, z] = foo (a, b, c)
% Do something with a, b, and c to make x, y, and z.
if (nargin != 3) % parens optional here
error ('usage: [x, y, z] = foo (a, b, c)');
else
x = 1/a; y = b; z = c^2;
endif % or, if you prefer, just `end'
end % or `endfunction' or just EOF if function is defined in a file
while RLaB uses an entirely different syntax (this is an example from
the RLaB distribution):
fact = function (f) {
if(f <= 1) {
return 1;
} else {
return f*$self(f-1);
}
}
(Note that to do this in Octave, you might write
function f = fact (x)
if (x <= 1)
f = 1;
else
f = x * fact (x-1);
endif
endfunction
though it would probably be better to avoid recursion for this
problem. :-)
The RLaB distribution contains a more complete list of differences
between it and Matlab.
In general, the syntax of Octave is very much like that of Matlab.
--
Virtually all of the programs obtained by our sampling | John W. Eaton
procedure were written in FORTRAN. -- Donald E. Knuth | jwe@che.utexas.edu
Technical Details
Message-ID:
<1iu31qINN6f9@geraldo.cc.utexas.edu>Path:
arc1-ca.pugleaf.net!sparky!uunet!cs.utexas.edu!geraldo.cc.utexas.edu!bongo.cc.utexas.edu!jweReferences:
<1iskmhINNokt@geraldo.cc.utexas.edu> <AJT.93Jan12171438@peregrin.resmel.bhp.com.au>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!cs.utexas.edu!geraldo.cc.utexas.edu!bongo.cc.utexas.edu!jwe From: jwe@bongo.cc.utexas.edu (John W. Eaton) Newsgroups: sci.math.num-analysis Subject: Re: Octave -- a high-level language for numerical computations Date: 12 Jan 1993 09:29:30 GMT Organization: The University of Texas at Austin, Austin TX Lines: 77 Distribution: world Message-ID: <1iu31qINN6f9@geraldo.cc.utexas.edu> References: <1iskmhINNokt@geraldo.cc.utexas.edu> <AJT.93Jan12171438@peregrin.resmel.bhp.com.au> NNTP-Posting-Host: bongo.cc.utexas.edu