ORDNUMSTR

버전 1.0.0.0 (1.81 KB) 작성자: Richie Cotton
Makes an ordinal numeral string from a number, e.g. 3 becomes 3rd.
다운로드 수: 1.4K
업데이트 날짜: 2008/7/31

라이선스 보기

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.

인용 양식

Richie Cotton (2024). ORDNUMSTR (https://www.mathworks.com/matlabcentral/fileexchange/20851-ordnumstr), MATLAB Central File Exchange. 검색 날짜: .

MATLAB 릴리스 호환 정보
개발 환경: R2008a
모든 릴리스와 호환
플랫폼 호환성
Windows macOS Linux
카테고리
Help CenterMATLAB Answers에서 Characters and Strings에 대해 자세히 알아보기
도움

도움 받은 파일: Number to Ordinal String Converter

도움 준 파일: Numeric to Ordinal-String

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
버전 게시됨 릴리스 정보
1.0.0.0

Bug fix: Input of integer ending 11, 12 or 13 now (really!) correctly handled.