Can't save rule in new matrix

1 回表示 (過去 30 日間)
fatema saba
fatema saba 2015 年 1 月 11 日
コメント済み: fatema saba 2015 年 1 月 11 日
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

採用された回答

Guillaume
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
  1 件のコメント
fatema saba
fatema saba 2015 年 1 月 11 日
thank you

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

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