Previous Page | Next Page

Language Reference

COUNTUNIQUE Function

COUNTUNIQUE( x <, method> ) ;

The COUNTUNIQUE function counts the number of unique values in a matrix. The arguments are as follows:

x

specifies an numerical or character matrix. The COUNTUNIQUE function counts the number of unique values in this matrix.

method

specifies the method used to count the missing values. This argument is optional. The following are valid values:

"all"

specifies that the function counts all unique values in the matrix. This is the default value. The function returns a matrix.

"row"

specifies that the function counts the unique values in each row. The function returns an matrix whose th element is the number of unique values in the th row of x.

"col"

specifies that the function counts the unique values in each column. The function returns a matrix whose th element is the number of unique values in the th 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;

Figure 23.66 Counts of Unique Values
allUnique
4

rowUnique
3
2
1
2

colUnique
1 3 4

Previous Page | Next Page | Top of Page