Placing values in a matrix with values from another matrix
1 view (last 30 days)
Show older comments
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.
0 Comments
Accepted Answer
More Answers (0)
See Also
Categories
Find more on Multidimensional Arrays in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!