【发布时间】:2020-04-14 10:26:31
【问题描述】:
从一个 for 循环中,我获得了一个矩阵列表。每个矩阵作为一个维度 [m*n]。我将 spettri_cp1 称为矩阵列表。目前我有 12 个矩阵。我想构建一个维度为 [m,12*n] 的单个矩阵。我尝试了这个循环,但我再次获得了一个新列表。 列表的维度 spettro_cp1 = [12,224,18]
mat_cp1=[] #i define the new matrix
for i in range(12):
for j in range(18):
frame = spettri_cp1[i,:,:] # from the list i extract the first matrix
spettro = frame[:,j] # from the first matrix i extract the single column
mat_cp1.append(spettro) # i append all the extracted column to build the new matrix
怎么了?
【问题讨论】:
-
最后一行的缩进似乎关闭了。
mat_cp1将等于最后一个spettro值。 -
谢谢。我还在循环之后添加了一个创建矩阵的命令: mat_cp1 = np.array(mat_cp1)
-
np.concatenate(); np.reshape()? docs.scipy.org/doc/numpy/reference/generated/…
标签: python arrays numpy sorting