Search code examples
pythonmatlabdata-structurescell

Matlab cell like structure in python


I am trying to generate a list of arrays in python similar to the Matlab code below:

for(t=1:Nmax)
    thisCell{t} = zeros(i,j,k)
end 

anyone has an idea how?


Solution

  • You can use a list comprehension and numpy:

    thisCell = [ numpy.zeros(shape=(i,j,k)) for t in range(1, Nmax) ]