title: Findpeaks in 3D (Surf) plot in Matlab
body: <p>I need to find several (~5) peaks in a 3D surf plot; tried imregionalmax but it's giving me too many maximums and I can't find a way to control it. </p>
  
  <p>I guess the actual peaks I need to find is in my z array which is (x by y), but findpeaks only works for a vector array. Is there an alternative? I've read something about the function squeeze- but not entirely sure how to put it into use it.</p>
  
  <p>The link is an example of the graph and the data points are the examples of the peaks I would need to know. </p>
  
  <p><a href="https://i.stack.imgur.com/GhpGe.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GhpGe.png" alt="enter image description here"></a></p>
  
  <p>If anyone could shed some light on this, it'd be great, thanks!</p>
  
  <p>A MCVE I used for imregionalmax is </p>
  
  <pre><code>Z = peaks;
  y = linspace(1,100,49);
  x = linspace(10,20,49);
  
  [X, Y] = meshgrid(x,y);
  
  figure
  surf(X, Y, Z,'EdgeColor','none','FaceColor','interp');
  maxZ = imregionalmax(Z);
  plot3(X(maxZ),Y(maxZ),Z(maxZ),'r*','MarkerSize',12)
  </code></pre>