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?
5 次查看(过去 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 个评论
回答(2 个)
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 ;
0 个评论
Bruno Luong
2022-3-30
编辑:Bruno Luong
2022-3-30
A = randi(10,2,3)
B = randi(10,2,3)
reshape([A;B], size(A,1), [])
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!