I have an index matrix, such as indexes = [1,3,1; 2,4,2; 1,3,1].
I have a matrix of values, such as values = [5,9,2; 3,4,1; 6.8.7].
I want to create a new matrix, combined = [5 + 2 + 6 + 7.9 + 8; 3 + 1.4] without using a for loop. A “combined” should consist of elements of matrix “values” combined together, assuming that their respective indices are in matrix “indices”.
Do you have any suggestions on how to approach this in MATLAB? Thank you in advance!
source
share