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