Skip to main content
14-Alexandrite
January 26, 2026
Solved

match and lookup functions

  • January 26, 2026
  • 2 replies
  • 433 views

Hi there 

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

thanks 

Yusra 

Best answer by LucMeekes

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

2 replies

LucMeekes23-Emerald IVAnswer
23-Emerald IV
January 26, 2026

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

14-Alexandrite
January 27, 2026

Thanks a lot 

25-Diamond I
January 26, 2026

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. πŸ™‚

 

 

 

 

 

14-Alexandrite
January 28, 2026

Hi Werner 

I'm trying to use this function, that you showed me before 

YA_10963798_0-1769589784913.png

to get q in the corresponding ztips depth

I wrote it like this 

YA_10963798_1-1769590237357.png

can you tell me what is wrong with this program 

Should I use match or change the iterator ? 

I attached the sheet 

Thanks

Yusra 

25-Diamond I
January 28, 2026

From the picture I see that your program does some calculations but at the end it returns "q" unchanged and that's what you finally get. πŸ˜‰

 

Could it be that you are looking for something like this:

Werner_E_2-1769596424183.png

 

The results are all NaN's because none of the values in ztips matches any  value in the vector ztop (which is then called z in the program).

I also suspect that you meant to use -z when you call the program and not ztop (qused := qs;d(q.-z,ztips). But this does not change the NaN's because none of the values in ztips matches any value in -z as well.
At least i guess that the second argument when calling qs;d should be a 2312x1 vector like the three vectors in q and not a 11x1 vector like ztop .

Werner_E_1-1769596371153.png

 

I can't remember what the question was when I provided the function you refer to and what the data was at that time.and I don't know what you intend to calculate now. Maybe you need to use a modifier like "geq", "lt", "near", etc. (see the help), but I can't possibly know.