Can you use the concatenation ability of MATLAB to combine a 3x4 and a 3x5 matrix?

조회 수: 7 (최근 30일)
If yes, how we can do this?
  댓글 수: 1
Stephen23
Stephen23 2017년 8월 31일
편집: Stephen23 2017년 8월 31일
[A,B]
horzcat(A,B)
cat(2,A,B)
Did you try searching for this before asking? MATLAB has documentation which is very easy to search.

댓글을 달려면 로그인하십시오.

채택된 답변

OCDER
OCDER 2017년 8월 31일
Yes you can, as long as the row or column dimensions matches.
A = zeros(3, 4) % A 3x4 matrix
B = ones(3, 5) % a 3x5 matrix
AB = cat(2, A, B) %Concatenate along column dimension (dim = 2), resulting in a 3x9 matrix
AB = [A B] %Same thing as cat(2, A, B)

추가 답변 (1개)

Omur Bas
Omur Bas 2017년 8월 31일
Simply use square brackets, as you would use for combining scalars into a vector:
A = ones(3,4);
B = zeros(3,5);
AB= [A B];

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by