I've got 30 5x116x116 MATLAB matrix that I want to import into python as a matrix. Unfortunately the only option I have found so far is using io.loaddmat which imports the mat file as a dictionary. Is there any way to import those 30 mat files into a 30x5x116x116 dimensional (np.)array?
1 Answer
It loads it as a dictionary because it includes the variable name. If you know the name of the variable you can easily index the original array (hopefully).
In matlab:
Array_name = ones(2,3,5,7).*rand
save('data.mat','Array_name')
In python:
import scipy.io as sio
mat_contents=sio.loadmat('data.mat')
### here is the original array
numpy_array=mat_contents['Array_name']
You can perform this action over all 30 of your files and combine them with numpy.concatenate