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.
Dave Kellow (2021). num2english (https://www.mathworks.com/matlabcentral/fileexchange/13577-num2english), MATLAB Central File Exchange. Retrieved .
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.
It also does not seem to handle early years well.
??? 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:
??? Error using ==> num2english
No such thing as a negative year.
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.
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!