You are now following this Submission
- You will see updates in your followed content feed
- You may receive emails, depending on your communication preferences
Makes an ordinal numeral string from a number, e.g. 3 becomes 3rd.
ORDNUMSTR(NUMBER) accepts a floating point number and appends a suitable suffix to form the ordinal numeral for the input (in English).
ORDNUMSTR(NUMBER, 0) simply returns the suffix.
The correct suffix in the case of non-integers is likely to stir up as much heated debate as 'what is best: emacs or vi?'. This function takes the last digit as the suffix generator, so that 81.3 becomes 81.3rd. The alternative would be to use the last digit before the decimal place to give 81.3st, but in my mind "threest" doesn't sound good. If you prefer the latter, then replace line 43 with line 44 and line 58 with line 59. Linguistic pendants may also note that in the case of non-integers, the numbers aren't really ordinal.
Update: Integers ending 11, 12 or 13 are now correctly given a 'th' suffix.
Cite As
Richie Cotton (2026). ORDNUMSTR (https://ch.mathworks.com/matlabcentral/fileexchange/20851-ordnumstr), MATLAB Central File Exchange. Retrieved .
Acknowledgements
Inspired by: Number to Ordinal String Converter
Inspired: Numeric to Ordinal-String
General Information
- Version 1.0.0.0 (1.81 KB)
MATLAB Release Compatibility
- Compatible with any release
Platform Compatibility
- Windows
- macOS
- Linux
| Version | Published | Release Notes | Action |
|---|---|---|---|
| 1.0.0.0 | Bug fix: Input of integer ending 11, 12 or 13 now (really!) correctly handled. |
