combining 5 rows into one matrix

5 visualizaciones (últimos 30 días)
Fadi Lama
Fadi Lama el 6 de Dic. de 2020
Respondida: VBBV el 20 de Jul. de 2022
How do I combine 5 different (1x10) vectors into a single matrix of dimension 5x10

Respuestas (2)

Cris LaPierre
Cris LaPierre el 6 de Dic. de 2020
mat1=1:10;
mat2=11:20;
mat3=21:30;
mat4=31:40;
mat5=41:50;
% Combine using square brackets and transpose to make 5x10
newMat = [mat1; mat2; mat3; mat4; mat5]'
newMat = 10×5
1 11 21 31 41 2 12 22 32 42 3 13 23 33 43 4 14 24 34 44 5 15 25 35 45 6 16 26 36 46 7 17 27 37 47 8 18 28 38 48 9 19 29 39 49 10 20 30 40 50

VBBV
VBBV el 20 de Jul. de 2022
mat1=1:10;
mat2=11:20;
mat3=21:30;
mat4=31:40;
mat5=41:50;
% transpose is not required to make 5x10
newMat = [mat1; mat2; mat3; mat4; mat5]
newMat = 5×10
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
transpose is not necessary

Categorías

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

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by