How to Import/Export Matlab *.mat file to Python?


The matlab variables (matrices, arrays) can be stored in *.mat files, in order to read this data in Python, you would need a scipy.io package.

import scipy.io

And, after that, the loadmat is the way to go.

mat = scipy.io.loadmat('file.mat')

Similarly, you can use savemat to export to *.mat files.

arr = [x**2 for x in xrange(10)]
scipy.io.savemat('file.mat', arr)

–EOF (The Ultimate Computing & Technology Blog) —

GD Star Rating
loading...
122 words
Last Post: Clean Uninstall of Visual Studio 2010 and 2012 and Install Free Visual Studio 2013 Community Version!
Next Post: [Software Review] - Search Everything

The Permanent URL is: How to Import/Export Matlab *.mat file to Python?

Leave a Reply