Read Matlab matrix into Python -



Read Matlab matrix into Python -

when i'm trying read matlab matrix python, next error

>>> scipy.io.loadmat("dynamical.mat") traceback (most recent phone call last): file "<stdin>", line 1, in <module> file "/usr/lib/python2.7/dist-packages/scipy/io/matlab/mio.py", line 151, in loadmat mr = mat_reader_factory(file_name, appendmat, **kwargs) file "/usr/lib/python2.7/dist-packages/scipy/io/matlab/mio.py", line 105, in mat_reader_factory mjv, mnv = get_matfile_version(byte_stream) file "/usr/lib/python2.7/dist-packages/scipy/io/matlab/miobase.py", line 221, in get_matfile_version % ret) valueerror: unknown mat file type, version 46, 48

the dynamical.mat file containing matrix

% size = 30 30 % nonzeros = 252 zzz = zeros(252,3); zzz = [ 1 1 1.4019896354966477e+01 1 2 0.0000000000000000e+00 1 3 0.0000000000000000e+00 ...

this question seems inactive while, allow 1 alternative in case still need read .mat file, assuming in format specified:

def read_mat( file_path ): import numpy np mat = open(file_path, 'r') mat.next() # % size = 30 30 length = int(mat.next().split()[-1]) mat.next() # zzz = zeros(18,3) mat.next() # zzz = [ ans = np.array([ map(float, mat.next().split()) in xrange(length) ]) mat.close() homecoming ans

python matlab python-2.7 scipy

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -