Tutorials > Getting Started > Task 4–3: Extracting Data from Matrices
Task 4–3: Extracting Data from Matrices
1. Define the following matrix.
2. Type X. To insert the row operator, press Ctrl+Shift+R. Type 0 in the empty placeholder and then evaluate the expression.
The first row of matrix X contains strings. You can use strings for adding headers in matrices. The rules for editing strings are slightly different than for editing numbers. For example, you can insert spaces in a string:
3. To extract the number of rows and columns from matrix X, call the rows and cols built-in functions.
4. To extract the numbers from matrix X, call the submatrix function.
The arguments for submatrix are as follows: the name of the matrix, the indices of the first and of the last rows to extract, the indices of the first and of the last columns to extract. Function arguments are described in the Help.
5. To extract the highest number from matrix Y, call max.
6. To extract the second column of Y, insert the column operator. The keyboard shortcut for the column operator is Ctrl+Shift+C.
You can combine functions and operators in expressions. For example, you can extract the lowest number from the second column of matrix Y:
Practice
Before you move on to the next exercise, define M, v, and P using different methods for inserting arrays.
Extract the second row of P and its highest number. You can check your result by evaluating P. Redefine the first element of P by a string, such as "header".