Siladittya Siladittya - 1 year ago 102
Python Question

Can't pass data from octave to python through command line arguments

I am calculating HoG feature descriptors in Octave and then I am trying to cluster those data in Python using scikit-learn.
For testing my code in Python I am trying to pass a 4000x2 data to Python.
I am calling the Python script from Octave using

system('python filename.py data')


and then trying to get the data using

sys.argv


but I am getting the second argument as a string 'data' and not the 4000x2 data that I am passing from Octave

What should I do so that I can get the original data in Python and not just the string 'data'

Answer Source

There's a python command built into octave. Alternatively, I would save as a .mat file, and open this in your python script using scipy.io.loadmat.

There's also eval_py and python_cmd from the symbolic package, but I'm not sure if this is appropriate for your particular use-case. The most general, matlab-compatible, and recommended way to do this would be the .mat one.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download