Example: Using the Comparison Option with the Lookup Functions
1. Define two input matrices A and B of equal dimensions
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:
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:
11. Write a program to convert a matrix to a vector
12. Use the program to convert matrix A to vector V
13. Find the length of the vector of points matched in matrix A
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.