merge two matrices after odd rows

1 回表示 (過去 30 日間)
Keren Grinberg
Keren Grinberg 2022 年 3 月 3 日
コメント済み: Keren Grinberg 2022 年 3 月 3 日
I have 2 matrices:
A=[1 1;1 1;1 1]
B=[2 3;4 5;6 7]
i want to get -
C=[1 1;2 3;1 1;4 5;1 1;6 7]
(ccombine every row of B after odd row in A)
i tried:
result = reshape(([A B].'),[],1)
but it gives me:
C=
1
1
2
3
1
1
4
5
....

回答 (1 件)

Alan Stevens
Alan Stevens 2022 年 3 月 3 日
Here's one way:
A=[1 1;1 1;1 1];
B=[2 3;4 5;6 7];
AB = [A B]';
C = reshape(AB,2,6)'
C = 6×2
1 1 2 3 1 1 4 5 1 1 6 7
  1 件のコメント
Keren Grinberg
Keren Grinberg 2022 年 3 月 3 日
thank you!

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

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by