Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我在 Matlab 中有一个AxB矩阵和两个二进制列向量Ax1和Bx1。如何选择对应于Ax1向量1的矩阵行?显然,我必须对另一个向量的列进行相同的操作。
提前致谢
非常简单,例如:
AxB = [1 2 3 4; 5 6 7 8; 9 10 11 12]; Ax1 = [0 1 1]; Bx1 = [1 0 1 0]; A_rows = AxB(Ax1 == 1,:); B_cols = AxB(:,Bx1 == 1);
结果:
A_rows: 5 6 7 8 9 10 11 12 B_cols: 1 3 5 7 9 11