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(:).'
  1 件のコメント
Sharon
Sharon 2012 年 3 月 23 日
thanks..

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by