If you're looking for the local maxima, and you have the Image Processing Toolbox, you can use the imregionalmax function. It returns a logical matrix that identifies the points that you need. From there, you can determine which regions you are specifically looking for.
[X,Y] = meshgrid(0:0.5:10, 0:0.5:10);
Z = min(cos(X) + sin(Y), 1.5);
surf(X, Y, Z);
ix = imregionalmax(Z);
hold on
scatter3(X(ix), Y(ix), Z(ix), 'r', 'LineWidth', 5);
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/189207/image.jpeg)