I have a problem: I want to create a Matlab like struct in Python. The struct I need to create has two fields: "val" and "sl". It has to be a 1x2 struct. The "val" field needs to have two 3x3 matrices inside (e.g A and B), while the "sl" field needs to have two values inside (e.g 137 and 159). The final struct should be like this:
val sl
3x3 137
3x3 159
In Matlab the code is: struct(1).val=A;struct(1).sl=137;struct(2).val=B;struct(2).sl=159
In python I've tried hval = fromarrays([[A, B], [137, 159]], names=['val', 'sl'])
but it gives me this error: File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/core/records.py", line 608, in fromarrays
raise ValueError("array-shape mismatch in array %d" % k)
ValueError: array-shape mismatch in array 1 Does anyone know how to solve this problem?