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: Quick way
Replies: 1   Last Post: Jul 29, 2013 10:36 AM

Advanced Search

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

Posts: 1
Registered: 7/26/13
Quick way
Posted: Jul 26, 2013 10:48 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

You can use logical operators with the find command. For example, if we have a matrix called matrix, as follows:

matrix = [1 6 8;...
3 -5 2;...
2 2 10];

and we want to find the indices corresponding to the maximum element in this matrix, we can simply use a condition like the following:

[ i_index j_index ] = find(matrix >= max(max(matrix))); % This is a one-liner.

In the above case, this will yield the matrix index pair [ i_index j_index] = [3,3], corresponding to the maximum


Date Subject Author
7/26/13
Read Quick way
Christopher
7/29/13
Read Re: Quick way
Steven Lord

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.