Path: news.mathworks.com!not-for-mail
From: "Sadik " <sadik.hava@gmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Find N maximum values in an array
Date: Sat, 20 Feb 2010 01:38:05 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 15
Message-ID: <hlneds$8ej$1@fred.mathworks.com>
References: <hlmlog$1re$1@fred.mathworks.com>
Reply-To: "Sadik " <sadik.hava@gmail.com>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1266629885 8659 172.30.248.38 (20 Feb 2010 01:38:05 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sat, 20 Feb 2010 01:38:05 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1666517
Xref: news.mathworks.com comp.soft-sys.matlab:609950

How about this?

Let your array be x.

[sortedX,sortingIndices]  = sort(x,'descend');

% sortedX will be in descending order. Therefore, the first N elements will be the N maximum values.

maxValues = sortedX(1:N);
maxValueIndices = sortingIndices(1:N);

Best.

"Athanasios " <athanasios_f@yahoo.gr> wrote in message <hlmlog$1re$1@fred.mathworks.com>...
> I have an array with M values and i want to find the N maximum values as well their indices..Any help?