Ask for creating new matrix from Odd-Indexed and Even-Indexed Elements
3 ビュー (過去 30 日間)
古いコメントを表示
Phat Pumchawsaun
2017 年 12 月 3 日
コメント済み: David Goodmanson
2017 年 12 月 3 日
Hi,
I have two existing matrix with element of 371x2 and I would like to create the new one with 743x2 by putting the odd row with first matrix and even row with the second matrix following sample below;
Matrix A
1 2
5 6
9 10
. .
. .
Matrix B
3 4
7 8
11 12
. .
. .
New matrix C
1 2
3 4
5 6
7 8
9 10
11 12
. .
. .
I try the code following below but it didn't work. Could you please correct my code.
C = zeros(743,2);
[C(1:2:end,:),C(2:2:end,:)] = (A,B);
Thanks
0 件のコメント
採用された回答
David Goodmanson
2017 年 12 月 3 日
編集済み: David Goodmanson
2017 年 12 月 3 日
Hi Phat,
you're close
C = zeros(742,2);
C(1:2:end,:) = A;
C(2:2:end,:) = B;
2 件のコメント
David Goodmanson
2017 年 12 月 3 日
right now C is 742x2 and your new matrix D is 371x1. You can't make a third column of C with it because it doesn't have enough rows. Would you put zeros for the rest of the rows?
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Matrix Indexing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!