在 Python 中存储来自 For 循环的多个矩阵

Storing Multiple Matrices from a For Loop in Python

我正在尝试将以下 Matlab 代码转换为 Python:

  n = 10 ;
  T = cell(1, n) ;
  for k = 1 : n
    T{1,k} = 20*k + rand(10) ;
  end

它存储了 for 循环生成的所有矩阵。如何在 Python 中编写类似的代码?

您可以使用普通列表:

import numpy as np
n = 10
t = []
for k in range(n):
  t.append(20 * (k+1) + np.random.rand(n,n))
print(t)