In Matlab, there is something called struct, which allow the user to have a dynamic set of matrices.
I’m basically looking for a function that allows me to index over dynamic matrices that have different sizes.
Example: (with 3 matrices)
- Matrix 1: 3×2
- Matrix 2: 2×2
- Matrix 3: 2×1
Basically I want to store the 3 matrices on the same variable. To called them by their index number afterward (i.e. Matrix[1], Matrx[2]). Conventional python arrays do not allow for arrays with different dimensions to be stacked.
I was looking into creating classes, but maybe someone her has a better alternative to this.
Thanks
Just use a tuple or list.
A tuple
matrices = tuple(matrix1, matrix2, matrix3)will be slightly more efficient;A list
matrices = [matrix1, matrix2, matrix3]is more flexible as you canmatrix.append(matrix4).Either way you can access them as
matrices[0]orfor matrix in matricies: pass # do stuff.