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

Community Tip - Did you know you can set a signature that will be added to all your posts? Set it here! X

Use vlookup over a vector?

dsochor
10-Marble

Use vlookup over a vector?

In the attached image (from Mathcad Prime 3.1) I'm able to use vlookup with a single value. Is it possible to use it with a vector of input values and return a vector of values?

ACCEPTED SOLUTION

Accepted Solutions
Werner_E
25-Diamond I
(To:dsochor)

I guess thats only possible if you define an auxiliary user function.

Here are two examples. The first hast the data matrix and the return column hardcoded in the function, the second is more generic.

Bild.png

Both function can be called with a single, scalar argument as well. So you may give them a more meaningful name and use them as vlookup replacement (if you only are interested in the fist find),

Bild.png

View solution in original post

3 REPLIES 3
Werner_E
25-Diamond I
(To:dsochor)

I guess thats only possible if you define an auxiliary user function.

Here are two examples. The first hast the data matrix and the return column hardcoded in the function, the second is more generic.

Bild.png

Both function can be called with a single, scalar argument as well. So you may give them a more meaningful name and use them as vlookup replacement (if you only are interested in the fist find),

Bild.png

Thanks Werner, as long as the order of shapes matches the look up matrix, your second solution works perfectly. Smiley Happy

 

Why can't a vector be placed directly into the vlookup?

 

 Thanks Werner.jpg

Werner_E
25-Diamond I
(To:dsochor)


@dsochor wrote:

Thanks Werner, as long as the order of shapes matches the look up matrix, your second solution works perfectly. Smiley Happy


No sure what you mean by that matching order??

 


Why can't a vector be placed directly into the vlookup?

Because vlookup already has a matrix argument. If the first argument is a matrix/vector, too, you would only be able to vectorize the call if both arguments are of the very same dimension.

But even if that would be the case and you vectorize, Mathcad would cycle through BOTH matrices and so would feed vlookup with a scalar as second argument and this would make vlookaup fail, because the second argument must be a matrix.

 

So just this (rather useless) example works:

Bild.png

Announcements

Top Tags