Combining K matrices in one matrix

1 visualización (últimos 30 días)
shdotcom shdotcom
shdotcom shdotcom el 11 de Nov. de 2018
Editada: shdotcom shdotcom el 11 de Nov. de 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?

Respuesta aceptada

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

Más respuestas (0)

Categorías

Más información sobre Matrices and Arrays en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by