SETDIF Function

SETDIF (A, B) ;

The SETDIF function returns as a row vector the sorted set (without duplicates) of all element values present in A but not in B. If the resulting set is empty, the SETDIF function returns an empty matrix with zero rows and zero columns.

The arguments to the SETDIF function are as follows:

A

is a reference matrix. It can be either numeric or character.

B

is the comparison matrix. It must be the same type (numeric or character) as A.

For character matrices, the element length of the result is the same as the element length of the A. Shorter elements in the second argument are padded on the right with blanks for comparison purposes.

The following statements produce the matrix C, which contains the elements of A that are not contained in B:

A = {1 2 4 5};
B = {3 4};
C = setdif(A, B);
print C;

Figure 24.366: Difference of Sets

C
1 2 5