title: MATLAB — finding max value in a region of 2D matrix
body: <p>Im having problem in finding how to find a max value in a defined region of 2D matrix. I need to find the coordinates, too.</p>
  
  <p>Right now, I have this:</p>
  
  <pre><code>B ... 2Dmatrix &lt;br&gt;
  [row_val row_ind] =max(B, [], 1) ;&lt;br&gt;
  [col_val col_ind] =max(row_val) ;&lt;br&gt;
  [r c] =find(B==max(B(:))) ;&lt;br&gt;
  [s_v s_i] =max(B(:)) ;&lt;br&gt;
  [r c] =ind2sub(size(B), s_i)&lt;br&gt;&lt;br&gt;
  </code></pre>
  
  <p>It just finds the coordinates of the largest value, but I can't choose the region of the matrix to look for the max value.</p>