cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Your Friends List is a way to easily have access to the community members that you interact with the most! X

How to access non-sequential array indices

ptc-5071035
1-Newbie

How to access non-sequential array indices

Sorry if this has been answered before. I have looked around for the last hour or two and can not seem to find anything about this. I've created my own function to solve this issue, but I can't help but think that it should be easier.

I would like to access an array with another array of indices. Unlike a range, these indices are non-sequential. When I try to access the array just like a range would, it says that the value must be an integer. I've also tried vectorizing it, to no avail.

Any insight you guys might have would be greatly appreciated. I'm using Mathcad Prime 2.0, by the way.

ACCEPTED SOLUTION

Accepted Solutions
Werner_E
25-Diamond I
(To:ptc-5071035)

What do you mean by "access" the first array? Selecting a subset of data values in the first vector given by another array of indices?

If yes, here are two possible solutions:

VectorSubset.png

View solution in original post

3 REPLIES 3
Werner_E
25-Diamond I
(To:ptc-5071035)

What do you mean by "access" the first array? Selecting a subset of data values in the first vector given by another array of indices?

If yes, here are two possible solutions:

VectorSubset.png

That's exactly what I was looking for! Thank you!

Werner_E
25-Diamond I
(To:ptc-5071035)

You are welcome.

Here is a third way using a local function and vectorization:

VectorSubset2.png

Announcements

Top Tags