Given a matrix Z (i, j) such that it maps two arrays X (i) and Y (j). I am trying to find the elements of Z (and therefore the corresponding X and Y) in a specific range.
Now I am doing the following using logical indexing. Given this example
X = 1:5;
Y = 1:5;
Z = [17 24 1 8 15
23 5 6 14 16
4 6 13 20 22
10 12 19 21 3
11 18 25 2 9]
Z((X>1 & X<4),Y==3)
This works fine, but now I want to find the minimum return values from this particular range,
What am i doing with
min(Z((X>1 & X<4),Y==3))
But now, how do I return the corresponding X and Y minimum values? Since my boolean indexing returns an array, all the methods I've tried so far return the min index in the response array, not the original Z-matrix.
I can not use
[row col] = find(Z==min(Z((X>1 & X<4),Y==3)))
Due to repetitions. What are my alternatives?