how do i join 2 matrices
1 回表示 (過去 30 日間)
古いコメントを表示
Johannes Deelstra
2022 年 11 月 22 日
コメント済み: Johannes Deelstra
2022 年 11 月 22 日
I have 2 matrices a and b, both having size 5 x 5
I want to combine these 2 in a new matrix c, such that c = [a(:,1) b(:,1) a(:,2) b(:,2) a(:,3) b(:,3) etc];
Is this the only way doing it or is there another way?
Thanks
Johannes
0 件のコメント
採用された回答
Cris LaPierre
2022 年 11 月 22 日
Yes, you could use vertical concatenation followed by reshape.
a= rand(5)
b=rand(5)+5
% brute force
c = [a(:,1) b(:,1) a(:,2) b(:,2) a(:,3) b(:,3)]
% using vertical concatenation and reshape
c2 = [a;b]
c2 = reshape(c2,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!