COUNTUNIQUE (x <, method> );
The COUNTUNIQUE function counts the number of unique values in a matrix. The arguments are as follows:
specifies an numerical or character matrix. The COUNTUNIQUE function counts the number of unique values in this matrix.
specifies the method used to count the missing values. This argument is optional. The following are valid values:
specifies that the function counts all unique values in the matrix. This is the default value. The function returns a matrix.
specifies that the function counts the unique values in each row. The function returns an matrix whose ith element is the number of unique values in the ith row of x.
specifies that the function counts the unique values in each column. The function returns a matrix whose jth element is the number of unique values in the jth column of x.
The method argument is not case-sensitive. The first three characters are used to determine the value.
For example, the following statements count unique values for the matrix x
:
x={1 2 3, 1 1 2, 1 1 1, 1 0 0}; allUnique = countunique(x); rowUnique = countunique(x, "ROW"); colUnique = countunique(x, "COL"); print allUnique, rowUnique, colUnique;