How do I insert one array into another?

3 ビュー (過去 30 日間)
L'O.G.
L'O.G. 2022 年 8 月 25 日
回答済み: Chunru 2022 年 8 月 25 日
I have two arrays with elements of type double. I want to insert the 1st column of array 2 after the 1st column of array 1, the 2nd column of array 2 after the 2nd column of array 1, and so on. How do I do this?

採用された回答

Chunru
Chunru 2022 年 8 月 25 日
a = reshape(1:12, 3, 4)
a = 3×4
1 4 7 10 2 5 8 11 3 6 9 12
b = reshape(13:24, 3, 4)
b = 3×4
13 16 19 22 14 17 20 23 15 18 21 24
% You stack a and b, then reshape it
a = reshape([a; b], 3, 8)
a = 3×8
1 13 4 16 7 19 10 22 2 14 5 17 8 20 11 23 3 15 6 18 9 21 12 24

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by