%% Select the region of interest
Subregion = A(rowStart:rowEnd, colStart:colEnd);
% find max value and get its index
[value, k] = max(Subregion(:));[i, j] = ind2sub(size(Subregion), k);
% move indexes to correct spot in matrix
i = i + rowStart-1;
j = j + colStart-1;
Original link to the solution is http://stackoverflow.com/questions/7677996/matlab-finding-max-value-in-a-region-of-2d-matrix