I am actually asking a question to Heinrich about calling a python function from Matlab. Sorry Leo, I might be spamming your inbox.
I need to call a python function from a Matlab environment. Is it possible?
Let's assume, I have the following python code:
y = x * x
I want to call squared(3) from Matlab workspace/code and get 9.
I posted this msg in Matlab newsreader but no-one replied. That's why I am replying in this thread.
"Heinrich Acker" wrote in message <email@example.comYaTP>...
> 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
> into your Matlab command window, you should see:
> >> system('C:\Python25\hello.py')
> Hello world!
> ans =
> 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')