how to store elements from 2 arrays into another array?

18 ビュー (過去 30 日間)
Hiba iqbal
Hiba iqbal 2018 年 4 月 4 日
コメント済み: Star Strider 2018 年 4 月 4 日
ex: a=[1,2,3,4,5]; b=[6,7,8,9,10]; i want in a new array in 1st row as 1,6 2nd row 2,7 and so on. how do i do it in matlab?

採用された回答

Star Strider
Star Strider 2018 年 4 月 4 日
Probably the easiest way:
a = [1,2,3,4,5];
b = [6,7,8,9,10];
c = [a(:) b(:)]
c =
1 6
2 7
3 8
4 9
5 10
The (:) subscript reference creates column vectors. These are then concatenated horizontally to create ‘c’.
  2 件のコメント
Hiba iqbal
Hiba iqbal 2018 年 4 月 4 日
thanks
Star Strider
Star Strider 2018 年 4 月 4 日
As always, my pleasure.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by