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

Re: Python from Matlab



Dear Alain,

There is the Matlab command "system", which you could use to call python scripts like that: system('python MyPythonScript.py');

We use that in the Auditory Modeling Toolbox for Matlab, where we call the python implementation of the cochlear model of Sarah Verhulst et al.

As for passing parameters between Matlab and python, we have an ugly solution only: we save Matlab variables in a mat file which are then read from the python script. In order to get the results back to Matlab, we use text files. While this is not an optimal way of passing parameters (maybe the upcoming Matlab version will reduce that pain, as Stephan already mentioned), at least it works for us at the moment.

Maybe that helps you.

Best regards,
Piotr

Alain de Cheveigne wrote:
Hi Marek, 

I am looking for the opposite: an easy, efficient  and reliable way to call Python from Matlab.  My programming environment nowdays is matlab and I can't easily change.  The best course that I see is to implement new code in Python and call it from matlab, and make the switch to Python when Python code reaches critical mass.  I suspect many people are in a similar position.

Alain


--
Piotr Majdak
Psychoakustik und Experimentelle Audiologie
Institut für Schallforschung
Österreichische Akademie der Wissenschaften
Wohllebengasse 12-14, 1040 Wien
Tel.: +43 1 51581-2511
Fax: +43 1 51581-2530
begin:vcard
fn:Piotr Majdak
n:Majdak;Piotr
org;quoted-printable;quoted-printable:=C3=96sterreichische Akademie der Wissenschaften;Institut f=C3=BCr Schallforschung
adr;quoted-printable:;;Wohllebengasse 12-14;Wien;;1040;=C3=96sterreich
email;internet:piotr@xxxxxxxxxx
tel;work:+43-1-51581-2511
tel;fax:+43-1-51581-2530
tel;home:+43-1-2938-480
tel;cell:+43-699-8133-5070
url:www.kfs.oeaw.ac.at
version:2.1
end:vcard