我有三个矩阵,称为Matrix 1,Matrix 2和Matrix 3(所有矩阵都有相同数量的行和列)。我需要将它们组合成一个矩阵(NM),但列的顺序不同,所以:
NM column 1 = 1st column of matrix 1
NM column 2 = 1st column of matrix 2
NM column 3 = 1st column of matrix 3
NM column 4 = 2nd column of matrix 1
NM column 5 = 2nd column of matrix 2
依旧......
任何人都可以帮助我吗?
谢谢。
答案 0 :(得分:3)
我认为这应该有效:
NM=reshape ([M1; M2; M3], size (M1, 1), []);
答案 1 :(得分:2)
易
M = vertcat(Matrix1, Matrix2, Matrix3);
M = reshape(M, size(Matrix1, 1), []);