# MATLAB: Find a local max and local min of a surface with noise

maxminnoisesurface

I got the matrix above How can I find de MAXIMUM & MINIMUM locals and put the X,Y coodinate into a vector X and a vector Y and when i plot X vs Y o got the dots representating the maximum and minumum values with different color for max and min ps. remember to consider the noise
        A=[0.5000   -0.2668   -0.4606   -0.0866   -0.1433   -0.2063    0.0020   -0.0684    0.0824    0.0618;    -0.0700   -0.1001   -0.6211       -2.0000   -0.6901   -0.5352   -0.5370    0.6527   -0.4742   -0.2398;       -0.0159    0.1090    0.0902   -0.3513   -0.5579   -0.2559   -0.1088    0.2090   -0.1592    0.0290;    0.3378    0.3437    0.4101    0.4995    0.3286    0.1963    0.0434    0.1998    0.2853    0.3430;    0.3673    0.3320    0.2836    0.3189    0.3596    0.1729    0.0493    0.2758    0.2314    0.3171;   -0.7621   -0.5151   -0.3759   -0.1816    0.1758    0.0306   -0.4316    0.1782   -3.0051   -1.9493;   -0.0107   -0.1784        -0.0642   -0.1268   -0.0137    0.0840   -0.1945    0.0944   -0.1449          -0.0296;    0.2212    0.1060    0.0321    3.0020    0.1965   -0.0060    0.0472    0.1958    0.1850    0.3266;    0.1410    0.2704    0.1225   0.2163    0.0337    0.1676    0.1012    0.1511    0.1105    0.3585;   0.1301    0.2741    0.0495    0.0251    0.1299    0.2433    0.0284   0.0727    0.1462    0.1443 ;]

 z=crop; [zmax,imax,zmin,imin] = extrema2(z,1); [m,n]=size(crop); y=1:m; x=1:n; [x,y]=meshgrid(x,y); crop(crop<=10)=nan figure hold on        plot3(x(imax),y(imax),zmax,'bo',x(imin),y(imin),zmin,'ro')       for i = 1:length(zmax)       text(x(imax(i)),y(imax(i)),zmax(i),['  ' num2str(zmax(i))])       end       for i = 1:length(zmin)        text(x(imin(i)),y(imin(i)),zmin(i),['  ' num2str(zmin(i))])       end      hold off  hold on  surf(crop)