I am trying to convert python data to matlab format. It is saving a matlab file that has a data_array of 3x7x5 double.
But I need a file with 1x3 Cell (matlab cell) and in each cell 7x5 double matrix should be there. I tried to create list of dictionaries using these array and than save to matlab format. But that didn't helped too.
import numpy as np
import scipy.io
mat1 = np.random.randint(1,100,35).reshape(7,5)
mat2 = mat1*10
mat3 = mat1*0.1
list_mat = [mat1, mat2, mat3]
scipy.io.savemat("test_py1.mat", {'dict_array': list_mat})
Description of sample matlab file;
sample_mat = scipy.io.loadma('sample_mat.mat')
type(sample_mat) => dic
var1 = sample_mat['key']
type(var1) => numpy.ndarray
var1.shape = 1 x a
var2 = var1[0,0]
type(var2) => numpy.ndarray
var2.shape = m x n
loadmatresult, and try to replicate that. A numericnumpyarray translates to a MATLAB matrix, though possibly with a change inorder(andorder Fmight be best).cellandstructconvert to some mix ofstructured arrayand object dtype.loadmat. dictionary['key'] = numpy.ndarray with shape 1 x m. Under this numpy array there are 20 numpy.ndarray with shape a x b. But when I am trying the same with my numpy array, it is saving variable in m x a x b shape. I have added the description of sample file in my que too.