Functions > Vector and Matrix > Other Array Functions > Example: Using the Comparison Option with the Lookup Functions
Example: Using the Comparison Option with the Lookup Functions
1. Define two input matrices A and B of equal dimensions
 A 20 56.44 115 56 96 97 57 80 57 51.4 150 57.5 B 60 70 50 80 10 20 50 40 45 102 151 104
2. Define variable z
3. Use the match function to find elements in matrix A that match z exactly
The function returns the row-column coordinates of the two matched elements in matrix A.
4. Write a program to display the elements found by the match function
5. Use the program to display the exactly matched elements when z=57
6. Use the lookup function to find elements in matrix B that correspond to the matched elements in matrix A
The function returns the matched elements themselves and not their row-column coordinates.
7. Write a program to display the elements found by the lookup function
8. Use the program to display the matched elements of matrix B when z=57
9. Use the two programs to display the elements found by the match and lookup functions using the comparison function f1
This comparison option matches matrix A element values within the r1 range:
 r1lo z 1 z r1hi z 1 z r1lo r1hi
 F z f1 L z f1
10. Use the two programs to display the elements found by the match and lookup functions using the comparison function f2
This comparison option matches matrix A element values outside the r2 range:
 r2lo z 50 z r2hi z 50 z r2lo r2hi
 F z f2 L z f2
11. Write a program to convert a matrix to a vector
12. Use the program to convert matrix A to vector V
 V S A l1 length V n 0 l1 1
13. Find the length of the vector of points matched in matrix A
 K F z f2 l2 length K
14. Write a program to insert the matched points into a new vector of equal length as V. The program writes -100 in unpopulated positions.
15. Plot the two vectors in a way that hides the -100 points of MV. Use horizontal markers to show the two levels of r2.
Of the twelve elements of vector V (or matrix A), the five matched elements fall outside the specified range of r2.