On Friday, April 3, 2009 5:59:02 PM UTC-5, Paul wrote: > "Oluwa KuIse" <email@example.com> wrote in message <firstname.lastname@example.org>... > Hello, > Can anyone pls tell me how I can find the second (or third) largest element in a matrix AND its position. The max function gives the largest element and its position but how do I find the second largest element and its position? if temp is your vector, you can get the second largest element as follows: [c,i] = max(temp(temp~=max(temp)))why would you sort it? this is the whole point of logical addressing in matlab.
[c,i] = max(temp(temp~=max(temp))) I like your answer. Could you show me how to write like this to fine the third max? Thanks sss