MATLAB: Returning Position in Array or Matrices for max() maximum Hello I'm wondering if there is a trick which can give you back the position (which row and which column) in matrices in which the max value is. max() only gives you the value. thanks for your help. Matthias Best Answer [maxval, maxidx] = max(YourMatrix(:));[row, col] = ind2sub(size(YourMatrix), maxidx); Related SolutionsMATLAB: How to find the maximum value in a matrix A = randi(100,7,6); % your matrixv = max(A(:)); % value[ii,jj] = find(A == v); % row and column number MATLAB: How to use the min() and max() functions If you want to use min or max, then don't name a variable with the name min, or max.which min -allwhich max -allWhat does that tell you?Never use variable names that conflict with a function name. Related QuestionI want to find in which row the minimum element isFind the minimum of a matrixMaxFinding maximum value of a column
Best Answer