Community Tip - Did you get an answer that solved your problem? Please mark it as an Accepted Solution so others with the same problem can find the answer easily. X
Hi there
What is the difference between ( match) and ( lookup ) function in mathcad prime 11
thanks
Yusra
Solved! Go to Solution.
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:
tells you that the 2 is found at row position 1 in colum 0.
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...:
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
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:
tells you that the 2 is found at row position 1 in colum 0.
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...:
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
Thanks a lot
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:
EDIT; Oh, too late—Luc has beaten me by one minute. 🙂
Hi Werner
I'm trying to use this function, that you showed me before
to get q in the corresponding ztips depth
I wrote it like this
can you tell me what is wrong with this program
Should I use match or change the iterator ?
I attached the sheet
Thanks
Yusra
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:
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 .
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.
Thanks for the explanation
It looks to me that in last time you often try to rewrite a function which used a single vector q as its argument to work for a nested matrix q.
Instead of modifying the function which already worked OK for a single vector, I would suggest writing a new function for the nested q which simply calls the existing and working function multiple times for every element in q, collects the results and returns them as nested matrix.
In your case this would look like this:
You may also make a function which can be used for single and for nested inputs equally well:
Of course all of this does not change the NaN's which are returned because there are no exact matching values.
Nice
Always an amazing reply . I fixed the input and get the answers needed
Thanks a lot
