Looking for the latest version? Download pymatlab-0.2.3.tar.gz (21.9 kB)
Name Modified Size Downloads / Week Status
pymatlab-0.2.3 2013-10-24 22 weekly downloads
pymatlab-0.2.2 2013-10-22 0
pymatlab-0.2.1 2013-10-16 0
pymatlab-0.1.3 2010-04-18 0
pymatlab-0.1.2 2010-04-09 0
README.txt 2013-10-24 4.1 kB 0
Totals: 6 Items   4.1 kB 2
===================================== Python interface to MATLAB (pymatlab) ===================================== This package lets Python users interface and communicate with MATLAB from Python. Pymatlab makes it easier for users to integrate a project with a large MATLAB codebase into python scripts by using MATLAB scripts as a part of the python program. The basic functionality of this package is to send data from Python to MATLAB's workspace to be able to run Matlab function on the data. After processing you retrieve back data to python. This enables you to process data with Mathlab's built in functions, toolboxes or Matlab-scripts. It is also possible to use MATLAB's to generate plots or other graphics. The package uses Numpy's ndarrays and translates them into MATLAB's mxarrays using Python's ctypes and Matlab's mx library. The interface to MATLAB's workspace in done through MATLAB's engine library. Download -------- Downloading is possible from PyPi_ and `SourceForge pymatlab files`__. Since pymatlab is hosted at SourceForge_ the latest development version is available from git. There are different branches available this is the ctypes variant. .. _PyPi: http://pypi.python.org .. _Files: http://sourceforge.net/projects/pymatlab/files/ .. _SourceForge: http://sourceforge.net __ Files_ Installing ---------- Standard installation method using pip, easy_install or 'python setup.py install'. Preparing to use pymatlab ------------------------- You need MATLAB_ from Mathworks properly installed on your local machine. .. _MATLAB: http://www.mathworks.se/products/matlab/ Linux: C-shell has to be installed in order to make the Matlab connection work. Also the path to the matlab binary needs to be set. $ sudo apt-get install csh $ export PATH = /opt/MATLAB/R2013a/bin:$PATH Win: On Windows make sure the Matlab DLLs are in your "Path" environment variable. This version is not tested in Windows but should be possible to run with some debugging efforts. Requirements ------------ - Python Version 2. - Matlab Versions 2009a,2010a,2013a tested. Presumably any version? - Numpy Any version? tested on version 1.3.0. Limitations ----------- The current version lets you transfer int16, int32, int64, float32 and float64 matrices of any rank. Any other types will probably fail or give unpredictable results. Using pymatlab -------------- First import: >>> import pymatlab Initialise the interpretor. >>> session = pymatlab.session_factory() Create an numpy-array to start the work. >>> from numpy.random import randn >>> a = randn(20,10,30) Send the numpy array a to the MATLAB Workspace to the variable 'A' >>> session.putvalue('A',a) Do something in matlab in MATLAB with variable A. Sucessfull commands return an empty string - if MATLAB generates an error the returning string holds the error message >>> session.run('B=2*A') >>> session.run('C') Traceback (most recent call last): ... RuntimeError: Error from Matlab: Error: MATLAB:UndefinedFunction with message: Undefined function or variable 'C'. <BLANKLINE> A trick to make larger scripts more failsafe with regards to syntax errors. Send a script to a string variable and run it with eval(). >>> mscript = """D = A ... for i=1:10 ... D = 2*D ... end ... """ >>> session.putvalue('MSCRIPT',mscript) >>> session.run('eval(MSCRIPT)') To retrive the variable back to python: >>> b = session.getvalue('B') >>> (2*a==b).all() True If you want to explicitly close the connection to the interpreter delete the instance. Normally Matlab will be close when the session variable runs out of scope. >>> del session Bugs, support and feature requests ---------------------------------- All bug reports, feature requests or support questions are directed to to pymatlab@molflow.com. Please consider to support us in our efforts by `donating to pymatlab`__. Your donations will be used to buy hardware and software licenses to be able to continue to develop this package. .. _Donations: http://sourceforge.net/donate/index.php?group_id=307148 __ Donations_
Source: README.txt, updated 2013-10-24

Thanks for helping keep SourceForge clean.

Screenshot instructions:
Red Hat Linux   Ubuntu

Click URL instructions:
Right-click on ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Briefly describe the problem (required):

Upload screenshot of ad (required):
Select a file, or drag & drop file here.

Please provide the ad click URL, if possible:

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks