Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: Index for max element in a matrix?
Replies: 8   Last Post: May 16, 2012 1:38 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Loren Shure

Posts: 1,349
Registered: 12/7/04
Re: Index for max element in a matrix?
Posted: Jun 11, 2008 9:23 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

In article <484f04fb$0$90270$14726298@news.sunsite.dk>, asd@asd.com
says...
> I have this matrix:
>
> A = [15 12 11;
> 20 44 23;
> 33 32 34];
>
>
> Is there a function in matlab that returns the x and y index for the
> maximum/minimum element? In this case the function should return (2,2).
>
> If I use:
>
> find(A==(max(max(A))))
>
> I just get 5.
>
>
>


[maxA,ind] = max(A(:));
[m,n] = ind2sub(size(A),ind)

--
Loren
http://blogs.mathworks.com/loren/



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.