Visualizing number of letters in a number
Edgar created this interesting visualization inspired by a blog post by @matthen2. The concept is simple.
- Start with a number between 1 and 99: e.g. "42"
- Spell out the number: "forty-two"
- Count the number of letters in the spelled out number, excluding hyphen: "8"
- 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.
- 类别:
- Picks
评论
要发表评论,请点击 此处 登录到您的 MathWorks 帐户或创建一个新帐户。