필터 지우기
필터 지우기

How can I append same size matrix vertically?

조회 수: 8 (최근 30일)
horizon
horizon 2019년 5월 28일
댓글: Stephen23 2019년 5월 28일
When I tried to append the following matrices, it automatically appended horizontally. How can I append like this vertically?
12 93 -1
67 -8 11
10 90 0
60 0 10
script
sample = [12 62; 93 -8; -1, 11];
sample2 = [10 60; 90 0; 0, 10];
new = [sample, sample2];
disp(new)
%result
12 62 10 60
93 -8 90 0
-1 11 0 10

채택된 답변

Alex Mcaulley
Alex Mcaulley 2019년 5월 28일
sample = [12 62; 93 -8; -1, 11];
sample2 = [10 60; 90 0; 0, 10];
new = [sample; sample2];

추가 답변 (1개)

Rik
Rik 2019년 5월 28일
Nothing here is happening automatically. With the comma you are telling Matlab that you want to concatenate horizontally. If you want to concatenate vertically you can either use the semicolon, or explicitly call the cat function.
Also, your inputs seem confusing. You can get closest to your stated output by transposing your two first.
sample = [12 62; 93 -8; -1, 11];
sample2 = [10 60; 90 0; 0, 10];
new = [sample'; sample2'];
new(2,1)=67;%or was this a typo?
disp(new)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

제품


릴리스

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by