MATLAB: How to compare some specific entries of a matrix, if I have their indices stored in 2 files

matrixmatrix manipulation

I have 2 files, that have numbers that represent rows and columns respectively, out of which I want to pick a pair at a time, and compare that corresponding element from a given matrix. For example, if I have matrices A and B, such that:-
A= [1,5,9] and B= [2,6,11]
Then I want to compare the (1,2), (5,6) and (9,11) elements of a matrix C, and return the indices of the largest value.
Originally, my matrix A and B are 19007×1 in size. And my matrix C is 5601×5601 in size.

Best Answer

idx = sub2ind(size(C), A, B)
result = max(C(idx));