How can I convert a number into a text string for their corresponding word in english ?
2 views (last 30 days)
Show older comments
I want to convert numbers into text strings for their corresponding words in english, for instance:
1---> 'one' ; 2 ---> 'two' ; 52 ---> 'fiftytwo' and so on
is there any functionality in matlab for this? Thanks in advance for any helpful answers : )
0 Comments
Accepted Answer
Stephen23
on 7 Dec 2015
Very easily using my FEX submission num2words:
Easy to use, plus options for customizing the format, case, scale, sig-figs, etc:
>> num2words(0)
ans = 'zero'
>> num2words(1024)
ans = 'one thousand and twenty-four'
>> num2words(-1024)
ans = 'negative one thousand and twenty-four'
>> num2words(1024, 'pos',true, 'case','title', 'hyphen',false)
ans = 'Positive One Thousand and Twenty Four'
>> num2words(1024, struct('type','ordinal', 'case','sentence'))
ans = 'One thousand and twenty-fourth'
>> num2words(1024, 'and',false, 'order',1) % round to the tens.
ans = 'one thousand twenty'
0 Comments
More Answers (1)
See Also
Categories
Find more on Cell Arrays in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!