MATLAB: Finding the row and column number in a matrix

mxnrow number

for a matrix [1 2 3 4 6 10 7 5 9] mXn matrix– how is it that i can find the min or max element and then find the row number and the column number for further use in calculations

Best Answer

data = rand(5, 3);
[maxNum, maxIndex] = max(data(:));
[row, col] = ind2sub(size(data), maxIndex);
Another less compact approach finds the max values for each column at first:
data = rand(5, 3);
[maxNumCol, maxIndexCol] = max(data);
[maxNum, col] = max(maxNumCol);
row = maxIndexCol(col);
Please read "help max" also.