How to convert digital numerals (1, 2, 3) into number words ('one', 'two', 'three')?
Mostrar comentarios más antiguos
I have input data like:
1
2
3
4
13
15
23
and I want the output like:
one
two
three
four
thirteen
fifteen
twenty three
13 comentarios
Atsushi Ueno
el 6 de Mayo de 2023
Atsushi Ueno
el 6 de Mayo de 2023
The toolbox says it's compatible with R2009b and later releases. I tried Number to Words in R2014b. Then, num2words_test.m and num2words_demo.m do work as expected.
>> num2words(912)
ans =
nine hundred and twelve
>> num2words_demo
Running num2words_demo...
(omitted)
>> num2words_test
警告: No string class.
> In num2words_test at 12
num2words_test.m|3124: 0 of 2773 testcases failed.
Rik
el 6 de Mayo de 2023
Try to make a MWE so we can run your code without any other dependencies and can reproduce your issue. The best way to do this is to use the code section in the editor and use the run button (in this case you would have to attach the num2words function). That way you can make sure we will see the same error message as you do.
John D'Errico
el 6 de Mayo de 2023
My VPI toolbox does have a conversion utility.
vpi2english(vpi('346464564754758564780903545899123423253679870795774685647565532522343253633425236564'))
ans =
'three hundred forty six sexvigintillion, four hundred sixty four quinvigintillion, five hundred sixty four quattuorvigintillion, seven hundred fifty four trevigintillion, seven hundred fifty eight duovigintillion, five hundred sixty four unvigintillion, seven hundred eighty vigintillion, nine hundred three novemdecillion, five hundred forty five octodecillion, eight hundred ninety nine septendecillion, one hundred twenty three sexdecillion, four hundred twenty three quindecillion, two hundred fifty three quattuordecillion, six hundred seventy nine tredecillion, eight hundred seventy duodecillion, seven hundred ninety five undecillion, seven hundred seventy four decillion, six hundred eighty five nonillion, six hundred forty seven octillion, five hundred sixty five septillion, five hundred thirty two sextillion, five hundred twenty two quintillion, three hundred forty three quadrillion, two hundred fifty three trillion, six hundred thirty three billion, four hundred twenty five million, two hundred thirty six thousand, five hundred sixty four '
Walter Roberson
el 7 de Mayo de 2023
Should 1100 be
- one thousand one hundred
- one thousand and one hundred
- one thousand, one hundred
- eleven hundred
Walter Roberson
el 7 de Mayo de 2023
English billion (one million million) or American billion (one thousand million) ?
"one thousand and one hundred"
Can you give a reference explaining or example showing "and" before the hundreds digit. Of course British and Commonwealth English requires the perfectly correct "and" before ones/tens digits, but that is unrelated to your example with "and" before the hundreds digit. I have never seen any English dialect that does that.
"English billion (one million million) or American billion (one thousand million) ?"
Walter Roberson
el 7 de Mayo de 2023
https://www.linguee.com/english-french/translation/one+thousand+and+one+hundred.html contains the example
[...]
conviction, to a fine
(multa) of not less than one thousand and one hundred and sixty-four euro and
sixty-nine cents (1 164,69)
[...]
Yes, that is indeed a curious mistake. It just goes to show, one should not rely on french lawyers for english language lessons. Nor indeed, should one simply take any random piece of text from the internet as "proof".
I also searched for this topic, and every single instance I count find (automated search for all thousands with all ones/tens of hundreds) produced only bad translations written by non-native speakers, e.g.:
Others were even worse... I am not sure how much I would trust websites that make statements like "If you enter 'two thousand and fifty', you wil get the result as '2017'." Ouch.
So far I have not found a single reputable reference which places the "and" before the hundreds. Do you have such a reference?
Walter Roberson
el 7 de Mayo de 2023
“Of the children of Simeon, mighty men of valour for the war, seven thousand and one hundred.”
"A surgery on twenty six thousand and three hundred seventy eight patients with convergent squint"
Using "and" in English numbers might not be as common, but is not wrong, which makes it a preference that the poster needs to decide about.
Quoting an academic article obtained by a quick internet search does not conclusively prove much about english language rules. Let me give you a little hint: lots of articles are not written by native english speakers (e.g. the one you quoted from).
I also did not ask for quotations of poetic phrases.
I was very seriously asking you for a reputable reference on language, e.g. Cambridge, Oxford, BBC, or the like. Because I would like to know, if that specific rule is actually codified by any reputable organisation. So far I cannot find any such source.
"Using "and" in English numbers might not be as common, but is not wrong, which makes it a preference that the poster needs to decide about"
Actually using AND is both correct and common: AND in numbers is standard in british english and (AFIAK) all types of commonwealth english, as well as in canadian english. My question was not about that.
Walter Roberson
el 7 de Mayo de 2023
Okay, what the University of Oxford style guide says is,
Spell out whole-number words for one to ten; use figures for numbers above ten.
Cambridge ... talks about it indirectly, It is conventional for STM titles to have numbers written out up to 10 and for H&SS titles to have numbers to be written out up to 100. -- if we understand "STM titles" to refer to any discussion of Science, Technology and Mathematics, and "H&SS titles" to refer to dicussions of Humanities and Social Sciences
BBC says to spell out (only) single digits, except in headlines single digits may be given numerically, but spell out "millions"and "billions" except in currencies or headlines, but that the numbers that start a sentence must be spelled out (including for headlines)
So... if we go by the reference sources you picked out, then neither one thousand and one hundred nor one thousand one hundred are acceptable, unless they happen to be the first word in a sentence or headline, in which case no rule is given about using or not-using and
"So... if we go by the reference sources you picked out, then neither one thousand and one hundred nor one thousand one hundred are acceptable, unless they happen to be the first word in a sentence or headline, in which case no rule is given about using or not-using and"
Descriptions of English grammar (as related to numbers) are certainly available from reputable sources. For example:
http://www.macmillandictionaries.com/MED-Magazine/July2004/21-Language-Awareness-Numbers-UK.htm (now sadly only in the Wayback Machine)
Also by teaching resources from reputable sources:
which explicitly states "Don’t use the word and to join millions and thousands or thousands and hundreds:"
Also by some reputable style guides (which in general are not grammar references, just... style guides):
These make it clear that "and" before tens/ones is a normal, standard, documented part of British English (the same also applies to Commonwealth English) and Canadian English. However, the BBC learning material explicitly states that the use of "and" between thousands and hundreds, as in your example, is not allowed in standard British English. The British English grammar rules are also very neatly explained in algorithmic form here:
Note how when recombining with thousands and higher (with tens/ones) the word "and" is explicitly used only in the absence of hundreds (because the construct you used with "and" linking thousands and hundreds is not used in British English or Commonwealth English). All sources I have for British English are consistent with this: in ten years of writing and maintaining NUM2WORDS and WORDS2NUM (with over one thousand referenced test-cases sourced online from around twenty-five websites and from grammar books, this topic just happens to be something I have read a lot about) no reputable grammar or teaching reference I have read has mentioned such a thing. No engineer or mathematician I have ever worked with or listened to, has used such a construct:
https://www.youtube.com/watch?v=Wim9WJeDTHQ -> "... thousand, eight hundred and ninety-nine"
https://www.youtube.com/watch?v=q6L06pyt9CA -> "four thousand, nine hundred"
So far every example of "and" between thousands and hundreds seems to be an error by non-native speakers or poetic.
So naturally I am very curious how you came up with that example: what specific English dialect or region does that?
Respuestas (1)
Hitesh
el 31 de En. de 2025
Hi Akhilesh,
You need to use "Number to Words" File Exchange. After extracting the "num2words" folder. Add it to the MATLAB path.
Run the following command in the Command Window:
num2words(1098)
For more information regarding the "Number to Words" File Exchange, kindly refer to the below MATLAB documentation:
Categorías
Más información sobre Creating and Concatenating Matrices en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!