Get Help

Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Community
- :
- PTC Mathcad
- :
- PTC Mathcad
- :
- Use vlookup over a vector?

Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

08-25-2017
02:52 PM

08-25-2017
02:52 PM

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?

Solved! Go to Solution.

Labels:

1 ACCEPTED SOLUTION

Accepted Solutions

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

08-25-2017
03:39 PM

08-25-2017
03:39 PM

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.

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),

3 REPLIES 3

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

08-25-2017
03:39 PM

08-25-2017
03:39 PM

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.

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),

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

08-29-2017
11:04 AM

08-29-2017
11:04 AM

Re: Use vlookup over a vector?

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

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

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

08-29-2017
05:14 PM

08-29-2017
05:14 PM

Re: Use vlookup over a vector?

@dsochor wrote:

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

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: