Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross 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
Sep 1, 2005
58
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
 
Replies continue below

Recommended for you

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.
 
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