How to concatenate two matrices

조회 수: 3 (최근 30일)
Sharon
Sharon 2012년 3월 23일
I need to concatenate two matrices
x=[ 1 2 3 4]
y=[5 6 7 8]
such that I get
z=[1 5 2 6 3 7 4 8]
  댓글 수: 2
Oleg Komarov
Oleg Komarov 2012년 3월 23일
Have you tried looking in the documentation for "concatenate"?
Sharon
Sharon 2012년 3월 23일
yes cat(2,x,y) gives me
ans=
1 2 3 4 5 6 7 8 and not
1 5 2 6 3 7 4 8

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

채택된 답변

Honglei Chen
Honglei Chen 2012년 3월 23일
z = [x;y];
z = z(:).'

추가 답변 (0개)

카테고리

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