I am trying to recreate some code from MatLab using numpy, and I cannot find out how to store a variable amount of matrices. In MatLab I used the following code:
for i = 1:rows
K{i} = zeros(5,4); %create 5x4 matrix
K{i}(1,1)= ET(i,1); %put knoop i in table
K{i}(1,3)= ET(i,2); %put knoop j in table
... *do some stuff with it*
end
What i assumed i needed to do was to create a List of matrices, but I've only been able to store single arrays in list, not matrices. Something like this, but then working:
for i in range(ET.shape[0]):
K[[i]] = np.zeros((5, 4))
K[[i]][1, 2] = ET[i, 2]
I've tried looking on https://docs.scipy.org/doc/numpy-dev/user/numpy-for-matlab-users.html but it didn't help me.
Looking through somewhat simular questions a dirty method seems to be using globals, and than changing the variable name, like this:
for x in range(0, 9):
globals()['string%s' % x] = 'Hello'
print(string3)
Is this the best way for me to achieve my goal, or is there a proper way of storing multiple matrices in a variable? Or am i wanting something that I shouldnt want to do because python has a different way of handeling it?
np.zeros), or make new ones withconcatenate. (Python dictionaries do grow with assignment.)