2

I have successfully implemented the python.m script (on the basis of perl.m) as advised on Call Python function from MATLAB.

I can call python functions and pass output as a string.

Are there any ways I could create python objects in run-time and call them to return (numbers encoded as strings are fine) values during MATLAB run-time?

Community
  • 1
  • 1
  • If you can run a script like `r=python('sqd.py','3.5')` you just need a wrapper function in MATLAB that returns `r` and make sure that the `py` script creates the objects. If you wish for the object to stay alive you either need a native port or socket. Another option is to run MATLAB from Python. – noumenal Jul 29 '16 at 15:41
  • @noumenal It seems I would need to use a native socket using something like Pyro4. I can see this working, but it does not feel like a simple, elegant solution. – A.L. Verminburger Aug 10 '16 at 08:50
  • Is it the object representation or the Python data type that you are interested in? If you only need to get the properties/structure consider JSON. – noumenal Aug 10 '16 at 08:52
  • Have you looked at http://www.mathworks.com/help/matlab/call-python-libraries.html?s_tid=gn_loc_drop ? – noumenal Aug 10 '16 at 08:56
  • 1
    @noumenal We are using an older version of MATLAB so some of the python connectivity features in latest version are not available to us. Have successfully implemented this connectivity using the Pyro4 library in Python, it is quite slow though :( – A.L. Verminburger Aug 12 '16 at 18:04
  • Not sure how to solve that. Make sure you are running on all cores. Otherwise, Octave could maybe be an option. https://pypi.python.org/pypi/oct2py What kind of functionality are you using MATLAB for that SciPy doesn't offer? – noumenal Aug 12 '16 at 19:26
  • 1
    @noumenal It is legacy MATLAB code that is gradually re-written in Python. We want to add all new features to the system in Python to minimise re-write work further down the line. – A.L. Verminburger Aug 13 '16 at 11:09
  • I would maybe check out [muppy](https://pythonhosted.org/Pympler/muppy.html) for identifying memory leaks in Python or the [MATLAB profiler](http://de.mathworks.com/help/matlab/ref/profile.html). Perhaps that could help you to figure out why it is slow. Also, are you running MATLAB with the `-nojava` option? – noumenal Aug 13 '16 at 12:27

0 Answers0