I have a matrix let's say, A. I have found the max value of each row and the index to which it corresponds. Now I need to find the values in another matrix, B, that correspond to the max indices of A.
A = [20 1 3; 7 3 4; 6 9 5][max_value max_index] = max(A,[],2)
So that
max_index = [1; 1; 2]B = [4 6 11; 10 20 15; 1 5 9]
However, every way I can think to do this gives me the following output:
B(max_index) = [4; 4; 10]
Because max_index only includes the column number from A where max_value is instead of the row and column associated with the max_value. Is there a way to get
B(max_index) = [4; 10; 5]
I have tried transposing max_index, this does nothing to help. I have tried using a for loop, but may not have used to correct implementation here. Any help would be greatly appreciated! Thanks!
Best Answer