File Exchange Pick of the Week

Our best user submissions

Visualizing number of letters in a number

Jiro's Pick this week is CountLettersNum by Edgar Guevara.
Edgar created this interesting visualization inspired by a blog post by @matthen2. The concept is simple.
  1. Start with a number between 1 and 99: e.g. "42"
  2. Spell out the number: "forty-two"
  3. Count the number of letters in the spelled out number, excluding hyphen: "8"
  4. Repeat steps 2 and 3 until the same number is reached: "eight" "5" "five" "4" "four" "4"
With Edgar's code, you can visualize this for all numbers from 1 to 99. To get the word representations of the numbers, I'm using another Pick from the past, Number to Words.
numbers = 1:99;
number_words = cell(size(numbers));
 
for id = 1:length(numbers)
number_words{id} = num2words(numbers(id));
end
 
plotDirectedGraph(numbers,number_words)
I modified Edgar's plotDirectedGraph function to animate the creation of the graph.
countletters_anim2.gif
Give this a try and leave a comment for Edgar.
|
  • print

评论

要发表评论,请点击 此处 登录到您的 MathWorks 帐户或创建一个新帐户。