MATLAB: How to find the max value and location within a matrix

matrixscript

I am working with a 7783×1 matrix, and I am trying to find the max value & its location. But I need to do it in the script and not in the command window. I have the matrix data saved as a FILE.mat in the same folder.

Best Answer

Try this, where m is your matrix
maxValue = max(m(:));
rows = find(m == maxValue); % Find all locations where m equals the max value of m
Related Question