I’m new to working with numpy arrays and I’m having trouble creating a structured array. I’d like to create something similar to a Matlab structure where the fields can be arrays of different shapes.
a=numpy.array([1, 2, 3, 4, 5, 6,]);
b=numpy.array([7,8,9]);
c=numpy.array([10,11,12,13,14,15,16,17,18,19,20]);
##Doesn't do what I want
data=numpy.array([a, b, c],dtype=[('a','f8'),('b','f8'),('c','f8')]);
I’d like data['a'] to return matrix a, data['b'] to return matrix b, etc. When reading in a Matlab structure, the data is saved in this format so I know it must be possible.
In python a dictionary is roughly analogs to a structure in Matlab. You could try the following to see if it works for you: