File Exchange

## num2english

version 1.0.0.0 (2.32 KB) by
Converts real numbers to plain english

Updated 08 Jan 2007

NUM2ENGLISH Convert numbers to plain english.
T = num2english(X) returns the plain english representation of the
number X. If X is a vector, it returns a character array with each
number in a different row.

T = num2english(X,'year') returns a string sounding more like a year,
for instance num2english(1984,'year') will return 'nineteen
eighty-four'. If the third digit is a zero it will return 'oh', so
num2english(1706,'year') returns 'seventeen oh-six'.

T = num2english(X,'th') returns first, second, third etc. instead of
one two three.

T = num2english(X,'example') returns a display of the various aspects
of the function.

### Cite As

Dave Kellow (2021). num2english (https://www.mathworks.com/matlabcentral/fileexchange/13577-num2english), MATLAB Central File Exchange. Retrieved .

John D'Errico

In general, this did ok. A few things could be improved. I'd have liked to see an H1 line. Lookfor needs that to work properly.

I know that it says this converts numbers to english. But if it does not work for complex numbers, then it should generate an error message, not a wildly incorrect result.

num2english(1+sqrt(-1))
ans =
one thousand

It also does not seem to handle early years well.

num2english(21,'year')
??? Undefined function or variable "engy".

Error in ==> num2english at 209
engy = strrep(engy,'zero','oh-oh');

Have you ever had a "bad" year? This will pick you up:

num2english(-1,'year')
??? Error using ==> num2english
No such thing as a negative year.

8-)

And its rather picky about the second argument. For example, it will not accept 'Year' in place of 'year'.

I wanted to rate this about a 3.5 because of the items listed above, but its a neat function, so I rounded up. I'd happily raise that rating.

##### MATLAB Release Compatibility
Created with R2006a
Compatible with any release
##### Platform Compatibility
Windows macOS Linux