How do I concatenate two matrices into alternating rows?

11 ビュー (過去 30 日間)
Janna Hinchliff
Janna Hinchliff 2021 年 8 月 26 日
回答済み: KSSV 2021 年 8 月 26 日
I have two 2x4 matrices (actual matrices I'm using are much bigger than this in both dimensions), say
[1,2,3,4;5,6,7,8] and [a,b,c,d;e,f,g,h]
and I want to combine them so that I get
[1,2,3,4;a,b,c,d;5,6,7,8;e,f,g,h]
I've tried to do this using the reshape function but haven't managed to get it to do what I want. Is this the best function to use?

採用された回答

KSSV
KSSV 2021 年 8 月 26 日
A = rand(2,4) ;
B = rand(2,4) ;
C(1:2:4,:) = A ;
C(2:2:4,:) = B ;

その他の回答 (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