Documentation Center

  • Trial Software
  • Product Updates
我们为许可用户提供了部分翻译好的中文文档。您只需登录便可查阅这些文档

isordinal

Determine whether input is ordinal categorical array

Syntax

Description

example

tf = isordinal(A) returns logical 1 (true) if A is an ordinal categorical array. Otherwise, isordinal returns logical 0 (false).

If a categorical array is ordinal, you can use relational operations for inequality comparisons, such as greater and less than, in addition to tests for equality.

Examples

expand all

Determine Whether Categorical Array Is Ordinal

Create a categorical array containing the sizes of 10 objects. Use the names small, medium, and large for the values 'S', 'M', and 'L'.

A = categorical({'M';'L';'S';'S';'M';'L';'M';'L';'M';'S'},...
    {'S','M','L'},{'small','medium','large'})
A = 

     medium 
     large 
     small 
     small 
     medium 
     large 
     medium 
     large 
     medium 
     small 

Determine if the categories of A have a mathematical ordering.

isordinal(A)
ans =

     0

A is not ordinal. You must use the 'Ordinal',true name-value pair argument in the function categorical to create an ordinal categorical array.

Input Arguments

expand all

A — Categorical arrayvector | matrix | multidimensional array

Categorical array, specified as a vector, matrix, or multidimensional array.

More About

expand all

Tips

  • To convert a categorical array, A, from nonordinal to ordinal, use A = categorical(A,'Ordinal',true).

  • To convert a categorical array, A, from ordinal to nonordinal, use A = categorical(A,'Ordinal',false).

See Also

|

Was this topic helpful?