I'm trying to save a dictionary whose values are numpy arrays of different length to a mat file so that collaborators can load the dictionary as a cell array in MATLAB.
An example of input:
data={traces: {0: array([], dtype=float64), 1: array([], dtype=float64),
2: array([], dtype=float64), 3: array([], dtype=float64),
4: array([], dtype=float64), 5: array([], dtype=float64),
6: array([], dtype=float64), 7: array([], dtype=float64),
8: array([], dtype=float64), 9: array([], dtype=float64)}}
savemat('test.mat', mdict=data)
However, I get the error:
TypeError: Could not convert {0: array([], dtype=float64), 1: array([], dtype=float64),
2:array([], dtype=float64), 3: array([], dtype=float64), 4: array([], dtype=float64),
5: array([], dtype=float64), 6: array([], dtype=float64), 7: array([], dtype=float64),
8: array([], dtype=float64), 9: array([], dtype=float64)} (type <type 'dict'>) to array
How can I save this dictionary to a mat file?