# isordinal

Determine if input is ordinal categorical array

## Syntax

``tf = isordinal(A)``

## Description

````tf = isordinal(A)` returns logical `1` (`true`) if the input 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 than and less than, in addition to tests for equality.```

example

## Examples

collapse all

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 = 10x1 categorical medium large small small medium large medium large medium small ```

Determine if the categories of `A` have a mathematical ordering.

`tf = isordinal(A)`
```tf = logical 0 ```

`A` is not ordinal. To create an ordinal categorical array, use the `Ordinal=true` name-value argument when you call the `categorical` function.

Convert `A` to an ordinal categorical array.

```ordinalA = categorical(A,Ordinal=true); tf = isordinal(ordinalA)```
```tf = logical 1 ```

collapse all

Input array.

## 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)`.

## Version History

Introduced in R2013b

expand all