From: Athanasios on
I have an array with M values and i want to find the N maximum values as well their indices..Any help?
From: Steven Lord on

"Athanasios " <athanasios_f(a)yahoo.gr> wrote in message
news:hlmlog$1rf$1(a)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?

Call SORT with two outputs.

--
Steve Lord
slord(a)mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ


From: Athanasios on
"Steven Lord" <slord(a)mathworks.com> wrote in message <hlmmoq$6ij$1(a)fred.mathworks.com>...
>
> "Athanasios " <athanasios_f(a)yahoo.gr> wrote in message
> news:hlmlog$1rf$1(a)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?
>
> Call SORT with two outputs.
>
> --
> Steve Lord
> slord(a)mathworks.com
> comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
>
and how i will get the indices of the N max values..? I m afraid i dont get it..

p.s Sorry for the double thread.. :((
From: Matt Fig on
> and how i will get the indices of the N max values..? I m afraid i dont get it..



Well, I have found that one of the best ways to learn MATLAB, is just to TRY IT. So make an array and try it. Use simple examples, and just look.

A = round(rand(1,7)*1000)
[As,IDX] = sort(A)

Now what relation do As and IDX have to A? Look at the help for sort if you can't see it.
From: Athanasios on
"Matt Fig" <spamanon(a)yahoo.com> wrote in message <hlmpar$m9i$1(a)fred.mathworks.com>...
> > and how i will get the indices of the N max values..? I m afraid i dont get it..
>
>
>
> Well, I have found that one of the best ways to learn MATLAB, is just to TRY IT. So make an array and try it. Use simple examples, and just look.
>
> A = round(rand(1,7)*1000)
> [As,IDX] = sort(A)
>
> Now what relation do As and IDX have to A? Look at the help for sort if you can't see it.

hmmm that a good hint... Thanks for this useful answer...I will try it...