Can't save rule in new matrix
1 回表示 (過去 30 日間)
古いコメントを表示
Hi I have two matrix
A= [0.1102 0.0612 0.1946
0.1812 0.1469 0.0379
0.1738 0.0037 0.0906]
B= [0.1116 0.1387 0.0650
0.0724 0.0913 0.1516
0.0765 0.1705 0.1225]
I want to create matrix C from matrix A and B. Matrix C has 6 rows and 3 column.
row 1 of Matrix C is like row 1 of Matrix A but Row 2 of Matrix C is like row 1 of Matrix B.again row 3 of matrix C is like row 2 of matrix A and row 4 of matrix C is like row 2 of matrix B. and this rule repeat for other rows.
the original of my matrix is very large and this is an example.
I write the code but I cant save C in matrix.
for i=1:m*n
C=[A(i);B(i)]
end
0 件のコメント
採用された回答
Guillaume
2015 年 1 月 11 日
Concatenate horizontally, transpose, reshape and transpose does it:
C = reshape([A B]', size(A, 2), [])'
C =
0.1102 0.0612 0.1946
0.1116 0.1387 0.0650
0.1812 0.1469 0.0379
0.0724 0.0913 0.1516
0.1738 0.0037 0.0906
0.0765 0.1705 0.1225
その他の回答 (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!