我正在尝试在 python 中实现一个 matlab 代码。 我有以下情况:
MATLAB 代码:
A = a b c d A=A(:) A = a
e f g h e
b
f
c
g
d
h
如何在 Python、MxN numpy 矩阵中获得相同的结果?
最佳答案
如果你使用的是numpy
,
A.flatten()
会导致
[[a b c d e f g h]]
你可以使用
A.transpose().flatten()
得到
[[a e b f c g d h]]
关于python - 我怎样才能将一个有n列的矩阵转换成只有一列的矩阵?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57192892/