Simple MATLAB- how to find indices of max element in matrix?

Click For Summary
SUMMARY

To find the indices of the maximum element in a 10x10 matrix using MATLAB, the function max() can be utilized effectively. While max() returns the maximum value by default, it can also return the index of that value when used with two output arguments. The correct syntax is [value, index] = max(matrix(:));, where matrix is the input matrix. This approach allows users to obtain the position of the maximum element directly.

PREREQUISITES
  • Basic understanding of MATLAB syntax
  • Familiarity with matrix operations in MATLAB
  • Knowledge of MATLAB functions and their outputs
  • Experience with indexing in MATLAB
NEXT STEPS
  • Explore the find() function in MATLAB for locating elements
  • Learn about reshaping matrices using reshape() in MATLAB
  • Investigate advanced indexing techniques in MATLAB
  • Study the use of logical indexing for conditional element retrieval in MATLAB
USEFUL FOR

MATLAB users, data analysts, and engineers looking to efficiently locate maximum values in matrices and enhance their matrix manipulation skills.

mikeph
Messages
1,229
Reaction score
18
Hi,

Say I have a 10x10 matrix, is there a simple code to finding the indices of the maximum value?

I'm trying to use max() but there doesn't appear to be any option of actually returning the index, rather than the value. I don't need the value, just the position.

Thanks,
Mike
 
Physics news on Phys.org
This thread on MATLAB Central should give you a decent answer: http://www.mathworks.com/matlabcentral/newsreader/view_thread/170759
 

Similar threads

  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 4 ·
Replies
4
Views
6K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 3 ·
Replies
3
Views
8K
Replies
5
Views
12K
  • · Replies 1 ·
Replies
1
Views
10K
  • · Replies 4 ·
Replies
4
Views
2K