Main Content

iptnum2ordinal

Convert positive integer to ordinal character vector

Description

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

example

Examples

collapse all

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

Version History

Introduced before R2006a