Main Content

iptnum2ordinal

Convert positive integer to ordinal character vector

Description

example

ordstr = iptnum2ordinal(number) converts the positive integer number to the ordinal character vector ordstr.

Examples

Convert Integers to Ordinal Numbers

Convert the number 4 to an ordinal number. The ordinal number is spelled out in entirety.

str = iptnum2ordinal(4)
str =

    'fourth'

Convert the number 23 to an ordinal number. The ordinal number consists of a numeral and the ordinal suffix 'rd'.

str = iptnum2ordinal(23)
str =

    '23rd'

Input Arguments

collapse all

Positive integer, specified as a numeric scalar.

Output Arguments

collapse all

Ordinal number, returned as a character vector.

  • Numbers less than or equal to twenty are spelled out.

  • Numbers greater than twenty consist of a numeral and an ordinal suffix: 'st' (for "first"), 'nd' (for "second"), 'rd' (for "third"), or 'th'.

Data Types: char

Introduced before R2006a