MATLAB: Locating matrix position of maximum value

MATLABmatrix

I have a large matrix with many numbers. I would like to calculate the max and min values as well as the cell location (m,n) of each of these values. How can I do this?

Best Answer

Use the full return argument of min and max
[Y,I] = MAX(X)
a=magic(10);
[Value,Ind]=max(a(:))
[M,N]=ind2sub(size(a),Ind)