I have a matrix, N, and a matrix RC, and what I want is to search for a minimum value in N based on values in RC for rows and columns. Each value in RC specifies a row and col that needs to be searched in N with column 1 representing row values and column 2 representing col values. How would I go about doing this? I tried doing
[minval, minidx] = min(min(N(RC(:,1), RC(:,2))))
but it is producing incorrect results leading me to believe there is an error in my logic. rmin and cmin are 2 and 1, respectively, which is not a pair in the RC matrix.
N = [0 1 5 12 1; 1 23 4 75 5; 11 29 2 5 9; 23 3 5 8 0; 12 11 23 48 0];RC = [1 3; 2 5; 2 3; 5 1; 2 4; 1 1; 1 5; 3 3];[minval, minidx] = min(min(N(RC(:,1), RC(:,2))));[rmin, cmin] = ind2sub(size(N), minidx)
Best Answer