REMOVE Function

REMOVE( matrix, indices ) ;

The REMOVE function discards elements from a matrix. The arguments to the REMOVE function are as follows:

matrix

is a numeric or character matrix or literal.

indices

specifies the indices of elements of matrix to remove.

The REMOVE function returns (as a row vector) a subset of the elements of the first argument. Elements that correspond to indices in the second argument are removed. The elements of the first argument are enumerated in row-major order, and the indices must be in the range 1 to , where matrix is an matrix. Nonintegral indices are truncated to their integer part. You can repeat the indices and give them in any order. If all elements are removed, the result is a null matrix (zero rows and zero columns).

The following statement removes the third element, which creates a row vector with three elements:

x = {5 6, 7 8};
a = remove(x, 3);      /* remove element 3 */
print a;

Figure 23.265 Result of Removing an Element
a
5 6 8

The following statement causes all but the fourth element to be removed:

r = {3 2 3 1};
b = remove(x, r);      /* equivalent to removing elements 1:3 */
print b;

Figure 23.266 Result of Removing Several Elements
b
8

The output shown in Figure 23.266 shows that repeated indices are ignored.