Combining K matrices in one matrix

1 次查看(过去 30 天)
Hi, I have K matrices of size [n,m]. For example:
K = 3;
n = 4;
m = 3
a = [1 2 3; 4 5 6; 7 8 9; 4 7 2];
b = [1 5 6; 3 1 2; 7 2 5; 6 8 3];
c = [4 1 7; 5 8 6; 3 5 9; 5 3 8];
X = [a11 b11 c11; a21 b21 c21; a31 b31 c31; a41 b41 c41;
a12 b12 c12; a22 b22 c22; a32 b32 c32; a42 b42 c42;
a13 b13 c13; a23 b23 c23; a33 b33 c33; a43 b43 c43];
% aij, bij and cij are the indexes of an element in matrix a, b and c
Is it possible to combine matrices a, b and c to create X, without using for statement?

采纳的回答

Bruno Luong
Bruno Luong 2018-11-11
X = reshape(cat(3,a,b,c),[],3)

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

标签

产品


版本

R2017a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by