How can I refer to a specific item of an array?


Hoyer
 Share

Recommended Posts

I have two arrays, which are filled with values every time when a specific event happens. The first item of the first array corresponds to the first item of the other array, e.t.c...

I want to determine where the minimum value of the first array is, and pick the value of the corresponding item from the other array.

I guess I should use filter and min commands together, but I suppose there would be a simpler solution.
Maybe I could simply get the index of the minimum value and simply pick the same index from the other.

How can I do that?

 

Thank you in advance!
Hoyer

Link to comment
Share on other sites

The trick to that is to use the time portion of the array to store the index.  Let's assume the arrays are arr1 and arr2:

arr1 = insertTime(arr1,0,1)

Then, to get the index of the minimum, just do gettime() on that minimum:

private theMin = min(arr1)
private indexMin = getTime(theMin)

Now you can just index into arr2 using indexMin.

Min() and Max(), in addition to returning the appropriate value, stick the time of that value into the time portion of the result.

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share