Ooops I just understood why the TypeError exception was raised ... In fact, this is the right way to pass a cell array of structures from Python to MATLAB but ... It seems that the scipy.io.savemat does not allow empty dictionary. Indeed If I complet all the dictionnaries all is working fine !:
In Python:
>>> import scipy.io as sio >>> import numpy as np
>>> toto = np.zeros((2,), dtype=np.object) >>> toto[0]={} >>> toto[1]={} >>> toto[1]['Site']=['Tataouine'] >>> toto[0]['weapon'] = np.zeros((2,), dtype=np.object) >>> toto[0]['weapon'][0]={} >>> toto[0]['weapon'][1]={} >>> toto[0]['weapon'][1]['Name']='fleurs' >>> toto[0]['weapon'][0]['Name']='bonbons' >>> toto array([ {'weapon': array([{'Name': 'bonbons'}, {'Name': 'fleurs'}], dtype=object)}, {'Site': ['Tataouine']}], dtype=object) >>> sio.savemat('toto.mat', {'toto':toto})
In MATLAB:
>> load('toto') >> toto
toto =
[1x1 struct] [1x1 struct]
>> toto{1}.weapon{2}.Name
ans =
fleurs
Hope this will help you to not waste your time with this silly problem !!