フィルターのクリア

Hi, If the numbers 1 to 5 are written out in words: one, two, three, four, five, then there are 3 + 3 + 5 + 4 + 4 = 19 letters used in total. Write a function called number2letters that returns the number of letters needed to write down the number

10 ビュー (過去 30 日間)
Hi, Really no idea how to start this question. PLease help.

採用された回答

KALYAN ACHARJYA
KALYAN ACHARJYA 2018 年 7 月 30 日
編集済み: KALYAN ACHARJYA 2018 年 7 月 30 日
You can do that by using this custom function
Here Answer:
n=input('Enter the number: ');
words_number=num2words(n);
disp(words_number);
str=upper(words_number(:));
AZ='A':'Z';
count=sum(ismember(str,AZ));
fprintf('The numbers of letter: %d',count);
%Make the function yourself, I hope now you can do that. Got the idea from here
  6 件のコメント
KALYAN ACHARJYA
KALYAN ACHARJYA 2018 年 7 月 31 日
Thank you @ Stephen Cobeldick

サインインしてコメントする。

その他の回答 (1 件)

Kavitha Komgari
Kavitha Komgari 2018 年 8 月 2 日
Hi, i have solved by writing first num2words and get a string. Then convert it to number of letters. Thank you for your answers.

Community Treasure Hunt

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

Start Hunting!

Translated by