For Programmers: Free Programming Magazines  


Home > Archive > Matlab > June 2007 > Python









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Python
Leo Garcia

2007-06-20, 8:14 am

You can run Python from the Windows Command Prompt and Matlab can
send commands to the Windows Command Prompt.

So far so good...

But when I try and run Python from Matlab behaving as the Windows
command prompt, nothing happens - where am I going wrong?

Many thanks

Leo
Heinrich Acker

2007-06-20, 8:14 am

Leo,

if you have trouble implementing something that you got as an answer
to your posting, it's definitely better to continue the thread
instead of staring a new one. That way, other people can see what's
been done to solve the problem. Also, the guy who spend some time to
help you does not feel ignored.

The reply I gave you to your posting "Matlab and Python" a few days
ago should work if you fill in the proper path information; if it
does not work for you, you should describe what you get on the basis
of the previous answer. It is very rare that *nothing* happens! As
you see below, the system command is supposed to return a value. That
value should 'happen', even if the command you issue has no effect.

If you have, for instance, the file 'hello.py' in your Python home
directory 'C:\Python25', with the content:

print "Hello world!"

and you type

system('C:\Python25\hello.py')

into your Matlab command window, you should see:
[color=darkred]
Hello world!
ans =
0

This assumes Windows, and the extension '.py' must be registered,
such that the OS knows it must start the python interpreter to run a
python script. If not, this should work:

system('C:\Python25\python C:\Python25\hello.py')

Regards,

Heinrich
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com