フィルターのクリア

How to concatenate first column of matrix A and first column of matrix B, then second column of matrix A and second column of matrix B and so on?

1 回表示 (過去 30 日間)
A = rand(128,4626);
B = rand(128,4626);
I would like to concatenate A and B together, but in this format: C = [A(:,1) B(:,1) A(:,2) B(:,2) ... A(:,4626) B(:,4626)]
Is this possible?
  2 件のコメント
Simon Chan
Simon Chan 2022 年 3 月 30 日
reply in your previous question.
C = reshape([A;B],[],2*size(A,2));
parslee
parslee 2022 年 3 月 30 日
Sorry I didn't see that, but thank you!

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

回答 (2 件)

KSSV
KSSV 2022 年 3 月 30 日
A = rand(128,4626);
B = rand(128,4626);
[m,n] = size(A) ;
iwant = zeros(m,2*n) ;
iwant(:,1:2:end) = A ;
iwant(:,2:2:end) = B ;

Bruno Luong
Bruno Luong 2022 年 3 月 30 日
編集済み: Bruno Luong 2022 年 3 月 30 日
A = randi(10,2,3)
A = 2×3
4 2 1 2 2 4
B = randi(10,2,3)
B = 2×3
7 1 7 4 3 2
reshape([A;B], size(A,1), [])
ans = 2×6
4 7 2 1 1 7 2 4 2 3 4 2

カテゴリ

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