In MATLAB when ever I had to make arrays of inhomogeneous data I would use arrays of structs. In Python 'Lists' can be used for that. Lists are indexed containers for any mixture of data. So for instance, I need to store event times for a series of nodes. The nodes go from 0..N-1 and each node has an array of event times (that can also be a zero length array) In Python we initialize this list of lists as
ras = [[]]*N #empty list with N elements
ras[9] = [2, 4] #10th node now has two events 2 and 4
ras[9].append(4) #and now a third event 4
ras = [None]*10
ReplyDeletecreates an empty list with 10 'slots'