×
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

Index of a value in an array

Index of a value in an array

Index of a value in an array

(OP)
Hi,

I'm very new to Mathcad (12), I'm trying to find the index that a particular value appears at in an array. Even better I need to know what index of the element with the highest value is.

I hope that makes sense, a quick example just in case:

say the array = (0,3,9,5,2)

I want a function to return 2 (the index of 9).

Thanks in advance,

Iain

RE: Index of a value in an array

shmmeee,


as long as you have an array, (a matrix with 1 row & 5 cols) as you describe in your post, cols(array) should return 5.   The function match(array) should return 2.  

If you start with a vector (with 5 rows & 1 col) then use rows(vector) to get 5.  match(vector) will return 2.  



regards,


chichuck

RE: Index of a value in an array

Match is the correct function, however the correct format is:

match(max(array),array)

This will return a vector containing the index of the maximum value in array.

Peter

RE: Index of a value in an array

You may find in your manual or in the software, sample problems that may help you with this task. For example, go to:
        - Resource Center
        - Quicksheet References
        - Vector and Matrices
        - Locating All Elements in an Array That Match a Condition.


Unfortunately, this particular example may not be for beginners. However, this may give you an idea what is require to solve this type of problem.

Good luck.

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