[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: octave to matlab conversion

From: Tom Holroyd
Subject: Re: octave to matlab conversion
Date: Sat, 8 Oct 2005 11:35:39 -0400 (EDT)

From a quick look at the SciPy level of Numerical Python, I would say
Matlab (Octave) is generally more concise syntactically.  For example,
instead of
as in Matlab, one seems to have to type
x = arange(0,1,0.1)
in SciPy.

More verbose, yes, and possibly more readable.
Personally, I might use arange(10) * .1 instead.

It also appears that the ':' operator is not generally available in
matrix/vector expressions,

Sure it is.  It's called the slice operator.

x = arange(10) * .1
array([ 0.3,  0.4,  0.5])

and matrix transposition with ' has no counterpart, etc.

What's wrong with transpose(x)?

In summary, one is really just working in Python with some objects defined to bring linear-algebra sorts of things to a higher level. There is no real math-syntax support on the level of Matlab at all.

But that's exactly the point. Python is a very powerful, general purpose, high-level language. You can add complex types such as matrices. Base Python already has hashed arrays, real string types, functional programming constructs, etc. You gain all the math stuff, and you can continue to write highly complex, yet still readable apps with fully operational classes and objects.

For matrices, I find it humorous that they are most easily entered
using Matlab syntax embedded in function arguments, such as

A = mat('[1 2 3; 4 5 6; 7 8 9]')
b = mat('[10 11 12]')

Normally you'd say something like

array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
array([[1, 2, 3],
       [4, 5, 6],
       [7, 8, 9]])

The mat() function is just a crutch.

Then, to solve "A x = b", one says
x = linalg.solve(A,b)
instead of "x = A\b".

You can of course do "from linalg import solve" and then say "x = solve(A, b)". Is that less readable than "x = A\b"?

I don't see being in a "real programming environment" as an issue ...

I do.

I think the true measure of the quality of a language is how intuitive, easy to learn, and expressive it is. Another great language is Perl (Pathologically Eclectic Report Language).

Wow, I never expected to see those two sentences next to each other. :-)

Matlab and Perl are the only languages I know in which sizable programs have a good chance of working on the first try.

Being able to write programs that work on the first try is a skill, which mainly involves being careful and knowing the target language. "Working" doesn't just mean "no syntax errors" either.

Being able to read, maintain, and modify sizeable programs, on the other hand, is greatly aided by a language with a clean design that isn't cluttered with gratuitous syntax.

That's what makes a great language, in my opinion: minimized software development time, and maximum readability.

Software maintenance can often take far more time, in the long run. I value simplicity and ease of modification.

Dr. Tom Holroyd
"A man of genius makes no mistakes. His errors are volitional and
are the portals of discovery." -- James Joyce

Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:
How to fund new projects:
Subscription information:

reply via email to

[Prev in Thread] Current Thread [Next in Thread]