Example: Inserting and Extracting Subarrays
Inserting a Subarray
Insert an array at a given position in a larger array, replacing the original elements.
1. Define the larger array:
2. Define the smaller array:
3. Enter the row and column number where the upper-left element of the smaller array goes:
4. Insert matrix B at position (r, c) inside of matrix A:
Extracting a Subarray
1. Define the input matrix:
2. Extract all elements common to rows 1 and 2 and columns 0, 1, and 2:
3. To reverse the order of the columns, swap the last two scalar arguments:
4. To reverse the order of the rows, swap the first two scalar arguments: