[SciPy-user] Matlab and Python

Zhiwen Chong zhiwen.chong at elf.mcgill.ca
Wed Jul 13 11:39:39 CDT 2005


On 13-Jul-05, at 8:45 AM, Howey, David A wrote:
> 1) can matrices/vectors be handled in the same way (this is the  
> power of matlab of course). eg. the matlab 'dot' notation which  
> operates element by element on matrices. using vectors greatly  
> speeds up code over for loops and makes it more compact.

The situation is the reverse in SciPy. A multiplication of two SciPy  
array objects defaults to an element-by-element multiplication (dot  
notation in MATLAB, .*, ./ etc.). If you want to do linear algebra in  
SciPy, you have to explicitly specify a Matrix object.

In [1]: from SciPy import mat
numerix Numeric 24.0b2

In [2]: a = mat('[1 2; 3 4]')

In [3]: a
Matrix([[1, 2],
        [3, 4]])

In [4]: a.T
Matrix([[1, 3],
        [2, 4]])

> 2) matlab has extremely powerful plotting facilities

I haven't been able to do any plotting with SciPy or Python yet  
because of an installation problem on my Mac OS X machine. And I  
admit, MATLAB does have a very usable plotting system.

> 3) object orientation. Actually I think python might excel here. I  
> get a bit frustrated with matlab objects (no passing by reference,  
> for example).

IMHO, MATLAB's object-oriented features are actually a bit of a hack  
compared to Python's.

Python passes lists, dicts, objects by reference, so if one wants to  
pass a copy, one actually has to explicitly do a copy/slice.
But interestingly, there are many nuances:
http://tinyurl.com/78mf8

> 4) creation of executables/binaries-- should be okay

On the Win32 platform there is py2exe, and Python is standard on many  
Unices including Mac OS X.

I've know a MATLAB compiler exists, but I haven't used it.

Zhiwen
-- 
"If the women don't find you handsome, they should at least find you  
handy." - Red Green



More information about the SciPy-user mailing list