How to simply save a set of example matrices in Matlab and load them directly in python:
http://docs.scipy.org/doc/scipy/reference/tutorial/io.html
EDIT:
or not sure how stable it is (just compiled a simple parser, which is probably better implemented in some other way), but something like:
import numpy as np def myMagicalM2ArrayFunction(s): tok = [] for t in s.strip('[]').split(';'): tok.append('[' + ','.join(t.strip().split(' ')) + ']') b = eval('[' + ','.join(tok) + ']') return np.array(b)
For 1D arrays, this will create a numpy array with the form (1, N), so you can use np.squeeze to get an array (N,) depending on what you are doing.
source share