The answer depends on what operations you would like to perform on your data and whether the dimensions and types will be the same. If you want to dynamically add elements of different types with different dimensions, a Dict
is a viable option.
The following code is the most similar to what you described above in Matlab. It is an array of Dictionaries. It assumes that each dictionary contains two dimensional arrays of Float64. This means you can add new key-value pairs, but only of the same type. (e.g. x[1][:d] = rand(30, 3)
). Otherwise, using type Any
will incur a performance penalty, which is fine if you need to have key-value pairs of different types.
k = 3
keys = [:a,:b,:c]
x = [Dict(key=>fill(0.0,1,1) for key in keys) for _ in 1:k]
x[1][:a] = rand(3, 2)
Aside from that, we would need to know more information about how you plan to use your data structure.