Filter löschen
Filter löschen

Combining K matrices in one matrix

2 Ansichten (letzte 30 Tage)
shdotcom shdotcom
shdotcom shdotcom am 11 Nov. 2018
Bearbeitet: shdotcom shdotcom am 11 Nov. 2018
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?

Akzeptierte Antwort

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

Weitere Antworten (0)

Kategorien

Mehr zu Matrices and Arrays finden Sie in Help Center und File Exchange

Produkte


Version

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by