Call Python function from MATLAB -


i need call python function matlab. how can this?

i had similar requirement on system , solution:

in matlab there function called perl.m, allows call perl scripts matlab. depending on version using located somewhere like

c:\program files\matlab\r2008a\toolbox\matlab\general\perl.m 

create copy called python.m, quick search , replace of perl python, double check command path sets point installation of python. should able run python scripts matlab.

example

a simple squared function in python saved "sqd.py", naturally if doing i'd have few checks in testing input arguments, valid numbers etc.

import sys  def squared(x):     y = x * x     return y  if __name__ == '__main__':     x = float(sys.argv[1])     sys.stdout.write(str(squared(x))) 

then in matlab

>> r=python('sqd.py','3.5') r = 12.25 >> r=python('sqd.py','5') r = 25.0 >> 

Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -