×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

How to get index number of an element in an array

How to get index number of an element in an array

How to get index number of an element in an array

(OP)
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

RE: How to get index number of an element in an array

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.

RE: How to get index number of an element in an array

and...

Check out the form that returns two values.

RE: How to get index number of an element in an array

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

RE: How to get index number of an element in an array

(OP)
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.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources