Placing values in a matrix with values from another matrix

1 回表示 (過去 30 日間)
stud123
stud123 2019 年 3 月 18 日
回答済み: Matt J 2019 年 3 月 18 日
Hello, I have some issues merging two different matrices.
I have one matrix, A (4915x90), and another matrix B (26x90). Matrix A contains only 0's and 1's and each column has 26 1's grouped together (i.e. two columns will never have 1's placed on the same row). I want to change all values given as 1's in each column in the A-matrix, with the values in each column in B. The values in each column in B (26 in total) are to be inserted in the same column in A, however, starting on a different rows depending on where the 26 1's are placed.
E.g., a shorter example.
A =
0 0 0
0 0 0
1 0 0
1 0 0
1 0 0
1 0 0
0 0 0
0 1 0
0 1 0
0 1 0
0 1 0
B =
1 4 0 % I want to insert the four values in column 1 in B into column 1 in A,
3 7 0 % and the values in column 2 in B into column 2 in A where the 1's are currently located
5 8 0
6 9 0
Any help on where to begin would be greatly appreciated as my Matlab-skills aren't too advanced.

採用された回答

Matt J
Matt J 2019 年 3 月 18 日

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMultidimensional Arrays についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by