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

Community Tip - Need help navigating or using the PTC Community? Contact the community team. X

Translate the entire conversation x

match and lookup functions

YA_10963798
14-Alexandrite

match and lookup functions

Hi there 

What is the difference between ( match) and ( lookup ) function in mathcad prime 11

thanks 

Yusra 

ACCEPTED SOLUTION

Accepted Solutions
LucMeekes
23-Emerald IV
(To:YA_10963798)

Match gives the location(s) (index/indices) of the element(s) found, while lookup gives the value(s) of all/an element(s) in (a) location(s) that correspond(s) to the element(s) found.

With matrix:

LucMeekes_0-1769441034898.png

LucMeekes_2-1769441058045.png

tells you that the 2 is found at row position 1 in colum 0.

LucMeekes_3-1769441095808.png

gives you the value in column 1 of that matrix, at the same row where 2 is found in the first column (column 0).

 

You can also get the value of the element found, by looking up in the same array as where you search...:

LucMeekes_4-1769441260658.png

but the usefullness of this may be questionable.

 

As Werner shows, you get multiple results, if the value you look for occurs multiple times in the array.

 

Success!

Luc

View solution in original post

3 REPLIES 3
LucMeekes
23-Emerald IV
(To:YA_10963798)

Match gives the location(s) (index/indices) of the element(s) found, while lookup gives the value(s) of all/an element(s) in (a) location(s) that correspond(s) to the element(s) found.

With matrix:

LucMeekes_0-1769441034898.png

LucMeekes_2-1769441058045.png

tells you that the 2 is found at row position 1 in colum 0.

LucMeekes_3-1769441095808.png

gives you the value in column 1 of that matrix, at the same row where 2 is found in the first column (column 0).

 

You can also get the value of the element found, by looking up in the same array as where you search...:

LucMeekes_4-1769441260658.png

but the usefullness of this may be questionable.

 

As Werner shows, you get multiple results, if the value you look for occurs multiple times in the array.

 

Success!

Luc

YA_10963798
14-Alexandrite
(To:LucMeekes)

Thanks a lot 

Werner_E
25-Diamond I
(To:YA_10963798)

match(z,A) returns a vector of indices of the position(s) z is found in matrix A

lookup(z,A,B) returns a vector of values from matrix B from the position(s) z is found in A

 

See the Prime help here: Lookup Functions

 

Simple example:

Werner_E_0-1769441482857.png

 

EDIT; Oh, too late—Luc has beaten me by one minute. 🙂

 

 

 

 

 

Announcements

Top Tags