isordinal

Tests whether a categorical array is ordinal.

Category: Language Fundamentals > Data Types

Syntax

tf = isordinal(C)

Returns true if the categorical array C has an ordering among its categories.

Description

An ordinal categorical array allows comparisons such as < and > and functions such as min and max, using the order in which the categories were listed. A nominal array (the default) allows only equality tests. Create an ordinal array with the 'Ordinal' option of categorical.

Input arguments

C
A categorical array.

Output arguments

tf
Logical scalar.

Example

Nominal and ordinal

n = categorical({'lo','hi'});
o = categorical({'lo','hi'}, {'lo','hi'}, 'Ordinal', true);
isordinal(n)
isordinal(o)
Output
ans = logical
   0
ans = logical
   1

See also

categorical isprotected categories