Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X
Hello Community,
I'm pretty new to Mathcad, so I'm sure I'm just missing something quite basic and obvious.
What I'm trying to achieve is to use the results returned by the match function, to extract the equivalent rows from another variable.
Given variable A and var. B use the match function to find the row index for values greater or equal to 2.5 in B, and use those indexes to create a new var. containing the values in A for the indexes (or just print directly from A).
The result I was expecting was the new variable to return "Ac" and "Ad".
I originally thought it should be a fairly easy task, something like the shown in "Approach 03" of the screenshot.
However, I'm finding all sort of errors when trying different approaches. The more predominant error bein: "This value must be and integer"
Any help, please?
Thanks! 🙂
Solved! Go to Solution.
Try using the function lookup instead of match.
Stuart
Of course!
It was as simple as using the right function 🤦
Thanks very much, Stuart.
You've saved me from (more) hours of looking at the screen and scratching my head!
🙂
Of course, as Stuart suggested, you should use “lookup” because this function does exactly what you want.
Just out of my own play instinct, two variants that still use “match” (not a recommendation!).
The first uses the already computed vector C with the index values to use and processes it in a loop.
The second variant uses “match” to find exactly the complementary indices and then uses them in the “trim” command to delete these lines.
As shown this also could be done in one go.
But as already mentioned, you sure should use “lookup” here and not fiddle around with "match".
Thanks very much for your reply, Werner.
Although Stuart gave us the correct solution, playful and adventurous solutions are most welcome too! (and even encouraged sometimes🙈)
Actually, your solution just adds a little bit more learning to the learnt from Stuart's solution!
Thanks both 🙂
@SC_12404331 wrote:
Thanks very much for your reply, Werner. @we
Although Stuart gave us the correct solution, playful and adventurous solutions are most welcome too! (and even encouraged sometimes🙈)
Actually, your solution just adds a little bit more learning to the learnt from Stuart's solution!
Thanks both 🙂
Apropos of nothing, I have an inordinate fondness for wolves (canis lupus not Wolverhampton Wanderers). I think it was Dave Mech, who once commented, "Too old to play, too old to be a wolf". I've occasionally wondered if the same isn't true for humans ...
Stuart
🙂
How true.
You may be interested in https://www.bps.org.uk/psychologist/golden-age-play-adults
BTW, would your passion include Werewolves as well?
@Werner_E wrote:
🙂
How true.
You may be interested in https://www.bps.org.uk/psychologist/golden-age-play-adults
Interesting. So, I’m a neotenous chimp. Figures. 😕
BTW, would your passion include Werewolves as well?
Not any more. I used to be a werewolf, but I’m alright NOOOWWWHHOOO! 🌕 🐺
Stuart