Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to get index number of an element in an array

Status
Not open for further replies.

bjbdts

Electrical
Joined
Sep 1, 2005
Messages
58
Location
US
Hi,
I'm calculating a frequency response of a variable. So basicly I have an array of frequency, and I have a corresponding array of the variable. My question is how can I get the index number of the maximum value of the variable?
Is there a simple command?
Thanks for your help.

bj
 
Type "help max" on the command line (without the quotes, of course).

xnuke
"Live and act within the limit of your knowledge and keep expanding it to the limit of your life." Ayn Rand, Atlas Shrugged.
Please see FAQ731-376 for tips on how to make the best use of Eng-Tips.
 
and...

Check out the form that returns two values.
 
Hi, I have the same problem but with median function.
So my question is how to get index number of median element (if it exists) in vector/array. (without using for loop)

[val,index]=median(x)
displays error: to many output arguments
It seems that this works only with max/min
 
Hi, ushy:
I guess the median(x) funcion calculates the median value of your array. For example, if x=0 1 2 3 4 5,
then median(x)=2.5, and 2.5 is not an element in the array.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top