combining 5 rows into one matrix

5 次查看(过去 30 天)
Fadi Lama
Fadi Lama 2020-12-6
回答: VBBV 2022-7-20
How do I combine 5 different (1x10) vectors into a single matrix of dimension 5x10

回答(2 个)

Cris LaPierre
Cris LaPierre 2020-12-6
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 2022-7-20
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

类别

Help CenterFile Exchange 中查找有关 Matrices and Arrays 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by