UNION Function

UNION (matrix1 <, matrix2, …, matrix15> ) ;

The UNION function returns a row vector that contains the sorted set of unique values of the arguments. If the matrices are thought of as sets, the return value is the union of the sets. If you call the UNION function with a single argument, the function returns the sorted elements with no duplicates.

There can be up to 15 arguments, which can be either all character or all numeric. For character arguments, the element length of the result is the longest element length of the arguments. Shorter character elements are padded on the right with blanks.

This function is identical to the UNIQUE function.

The following statements compute the union of the elements in two matrices:

a = {1 2 4 5};
b = {3 4};
c = union(a, b);
print c;

Figure 24.415: Union of Elements

c
1 2 3 4 5