Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Finding the position of the maximum of an array ?

Subject: Finding the position of the maximum of an array ?

From: Luka Djigas

Date: 19 Nov, 2009 02:56:43

Message: 1 of 3

Apart from the "usual" loop method, does matlab know a better way of
finding the position of a maximum value in x(1:100) array ?

Say I have, an array with 100 values inside. The maximum is at the
position 53. How to get that position in a variable ?


All ideas appreciated ...

With best regards,
Luka

Subject: Finding the position of the maximum of an array ?

From: Steven Lord

Date: 19 Nov, 2009 03:09:45

Message: 2 of 3


"Luka Djigas" <ldigas@___gmail___.com> wrote in message
news:csc9g5paf87a3g0bepth3sb6c7i2v5rhkh@4ax.com...
> Apart from the "usual" loop method, does matlab know a better way of
> finding the position of a maximum value in x(1:100) array ?
>
> Say I have, an array with 100 values inside. The maximum is at the
> position 53. How to get that position in a variable ?

Use the second output of the MAX function.

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

Subject: Finding the position of the maximum of an array ?

From: Matt Fig

Date: 19 Nov, 2009 04:12:01

Message: 3 of 3

"Steven Lord" <slord@mathworks.com> wrote in message
> Use the second output of the MAX function.

That's what I think of as the "usual" method!


To the OP, if there could be more than one location for the same maximum value and you want to know all locations, you may want to look at the FIND function.

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us