{"id":16706,"date":"2024-10-01T22:49:33","date_gmt":"2024-10-02T02:49:33","guid":{"rendered":"https:\/\/blogs.mathworks.com\/pick\/?p=16706"},"modified":"2024-10-01T22:49:33","modified_gmt":"2024-10-02T02:49:33","slug":"visualizing-number-of-letters-in-a-number","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/pick\/2024\/10\/01\/visualizing-number-of-letters-in-a-number\/","title":{"rendered":"Visualizing number of letters in a number"},"content":{"rendered":"<div class = rtcContent><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(33, 33, 33); font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><a href = \"https:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/869871\"><span>Jiro<\/span><\/a><span>'s Pick this week is <\/span><a href = \"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/172905\"><span>CountLettersNum<\/span><\/a><span> by <\/span><a href = \"https:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/1000530\"><span>Edgar Guevara<\/span><\/a><span>.<\/span><\/div><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(33, 33, 33); font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><span>Edgar created this interesting visualization inspired by a <\/span><a href = \"https:\/\/blog.matthen.com\/post\/8554780863\/pick-a-number-between-1-and-99-write-it-as-a\" target=\"_blank\"><span>blog post<\/span><\/a><span> by <\/span><a href = \"https:\/\/x.com\/matthen2\" target=\"_blank\"><span>@matthen2<\/span><\/a><span>. The concept is simple.<\/span><\/div><ol  style = 'margin: 10px 0px 20px; padding-left: 0px; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-size: 14px; '><li  style = 'margin-left: 56px; line-height: 21px; min-height: 0px; text-align: left; white-space: pre-wrap; '><span>Start with a number between 1 and 99: e.g. \"<\/span><span style=' font-weight: bold;'>42<\/span><span>\"<\/span><\/li><li  style = 'margin-left: 56px; line-height: 21px; min-height: 0px; text-align: left; white-space: pre-wrap; '><span>Spell out the number: \"<\/span><span style=' font-weight: bold;'>forty-two<\/span><span>\"<\/span><\/li><li  style = 'margin-left: 56px; line-height: 21px; min-height: 0px; text-align: left; white-space: pre-wrap; '><span>Count the number of letters in the spelled out number, excluding hyphen: \"<\/span><span style=' font-weight: bold;'>8<\/span><span>\"<\/span><\/li><li  style = 'margin-left: 56px; line-height: 21px; min-height: 0px; text-align: left; white-space: pre-wrap; '><span>Repeat steps 2 and 3 until the same number is reached: \"<\/span><span style=' font-weight: bold;'>eight<\/span><span>\" <\/span><span style=\"font-family: STIXGeneral-webfont, serif; font-style: normal; font-weight: 400; color: rgb(33, 33, 33);\">\u2192<\/span><span> \"<\/span><span style=' font-weight: bold;'>5<\/span><span>\" <\/span><span style=\"font-family: STIXGeneral-webfont, serif; font-style: normal; font-weight: 400; color: rgb(33, 33, 33);\">\u2192<\/span><span> \"<\/span><span style=' font-weight: bold;'>five<\/span><span>\" <\/span><span style=\"font-family: STIXGeneral-webfont, serif; font-style: normal; font-weight: 400; color: rgb(33, 33, 33);\">\u2192<\/span><span> \"<\/span><span style=' font-weight: bold;'>4<\/span><span>\" <\/span><span style=\"font-family: STIXGeneral-webfont, serif; font-style: normal; font-weight: 400; color: rgb(33, 33, 33);\">\u2192<\/span><span> \"<\/span><span style=' font-weight: bold;'>four<\/span><span>\" <\/span><span style=\"font-family: STIXGeneral-webfont, serif; font-style: normal; font-weight: 400; color: rgb(33, 33, 33);\">\u2192<\/span><span> \"<\/span><span style=' font-weight: bold;'>4<\/span><span>\"<\/span><\/li><\/ol><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(33, 33, 33); font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><span>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 <\/span><a href = \"https:\/\/blogs.mathworks.com\/pick\/2015\/01\/09\/spelling-out-numbers\/\"><span>Pick<\/span><\/a><span> from the past, <\/span><a href = \"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/47221\"><span>Number to Words<\/span><\/a><span>.<\/span><\/div><div style=\"background-color: #F5F5F5; margin: 10px 15px 10px 0; display: inline-block\"><div class=\"inlineWrapper\"><div  style = 'border-left: 1px solid rgb(217, 217, 217); border-right: 1px solid rgb(217, 217, 217); border-top: 1px solid rgb(217, 217, 217); border-bottom: 0px none rgb(33, 33, 33); border-radius: 4px 4px 0px 0px; padding: 6px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: rgb(33, 33, 33); font-family: Menlo, Monaco, Consolas, \"Courier New\", monospace, Menlo, Monaco, Consolas, \"Courier New\", monospace; font-size: 14px; '><span style=\"white-space: pre\"><span >numbers = 1:99;<\/span><\/span><\/div><\/div><div class=\"inlineWrapper\"><div  style = 'border-left: 1px solid rgb(217, 217, 217); border-right: 1px solid rgb(217, 217, 217); border-top: 0px none rgb(33, 33, 33); border-bottom: 0px none rgb(33, 33, 33); border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: rgb(33, 33, 33); font-family: Menlo, Monaco, Consolas, \"Courier New\", monospace, Menlo, Monaco, Consolas, \"Courier New\", monospace; font-size: 14px; '><span style=\"white-space: pre\"><span >number_words = cell(size(numbers));<\/span><\/span><\/div><\/div><div class=\"inlineWrapper\"><div  style = 'border-left: 1px solid rgb(217, 217, 217); border-right: 1px solid rgb(217, 217, 217); border-top: 0px none rgb(33, 33, 33); border-bottom: 0px none rgb(33, 33, 33); border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: rgb(33, 33, 33); font-family: Menlo, Monaco, Consolas, \"Courier New\", monospace, Menlo, Monaco, Consolas, \"Courier New\", monospace; font-size: 14px; '>&nbsp;<\/div><\/div><div class=\"inlineWrapper\"><div  style = 'border-left: 1px solid rgb(217, 217, 217); border-right: 1px solid rgb(217, 217, 217); border-top: 0px none rgb(33, 33, 33); border-bottom: 0px none rgb(33, 33, 33); border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: rgb(33, 33, 33); font-family: Menlo, Monaco, Consolas, \"Courier New\", monospace, Menlo, Monaco, Consolas, \"Courier New\", monospace; font-size: 14px; '><span style=\"white-space: pre\"><span style=\"color: #0e00ff;\">for <\/span><span >id = 1:length(numbers)<\/span><\/span><\/div><\/div><div class=\"inlineWrapper\"><div  style = 'border-left: 1px solid rgb(217, 217, 217); border-right: 1px solid rgb(217, 217, 217); border-top: 0px none rgb(33, 33, 33); border-bottom: 0px none rgb(33, 33, 33); border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: rgb(33, 33, 33); font-family: Menlo, Monaco, Consolas, \"Courier New\", monospace, Menlo, Monaco, Consolas, \"Courier New\", monospace; font-size: 14px; '><span style=\"white-space: pre\"><span >    number_words{id} = num2words(numbers(id));<\/span><\/span><\/div><\/div><div class=\"inlineWrapper\"><div  style = 'border-left: 1px solid rgb(217, 217, 217); border-right: 1px solid rgb(217, 217, 217); border-top: 0px none rgb(33, 33, 33); border-bottom: 0px none rgb(33, 33, 33); border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: rgb(33, 33, 33); font-family: Menlo, Monaco, Consolas, \"Courier New\", monospace, Menlo, Monaco, Consolas, \"Courier New\", monospace; font-size: 14px; '><span style=\"white-space: pre\"><span style=\"color: #0e00ff;\">end<\/span><\/span><\/div><\/div><div class=\"inlineWrapper\"><div  style = 'border-left: 1px solid rgb(217, 217, 217); border-right: 1px solid rgb(217, 217, 217); border-top: 0px none rgb(33, 33, 33); border-bottom: 0px none rgb(33, 33, 33); border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: rgb(33, 33, 33); font-family: Menlo, Monaco, Consolas, \"Courier New\", monospace, Menlo, Monaco, Consolas, \"Courier New\", monospace; font-size: 14px; '>&nbsp;<\/div><\/div><div class=\"inlineWrapper outputs\"><div  style = 'border-left: 1px solid rgb(217, 217, 217); border-right: 1px solid rgb(217, 217, 217); border-top: 0px none rgb(33, 33, 33); border-bottom: 1px solid rgb(217, 217, 217); border-radius: 0px; padding: 0px 45px 4px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: rgb(33, 33, 33); font-family: Menlo, Monaco, Consolas, \"Courier New\", monospace, Menlo, Monaco, Consolas, \"Courier New\", monospace; font-size: 14px; '><span style=\"white-space: pre\"><span >plotDirectedGraph(numbers,number_words)<\/span><\/span><\/div><div  style = 'color: rgb(33, 33, 33); padding: 10px 0px 6px 17px; background: rgb(255, 255, 255) none repeat scroll 0% 0% \/ auto padding-box border-box; font-family: Menlo, Monaco, Consolas, \"Courier New\", monospace; font-size: 14px; overflow-x: hidden; line-height: 17.234px; '><div class=\"inlineElement eoOutputWrapper disableDefaultGestureHandling embeddedOutputsFigure\" uid=\"FD7B731E\" prevent-scroll=\"true\" data-testid=\"output_0\" tabindex=\"-1\" style=\"width: 1146px;\"><div class=\"figureElement eoOutputContent\" role=\"article\" aria-roledescription=\"Use Browse Mode to explore \" aria-description=\"figure output \"><img decoding=\"async\" class=\"figureImage figureContainingNode\" src=\"https:\/\/blogs.mathworks.com\/pick\/files\/potw_countLetters_1.png\" style=\"width: 560px;\"><\/div><div class=\"outputLayer selectedOutputDecorationLayer doNotExport\" aria-hidden=\"true\"><\/div><div class=\"outputLayer activeOutputDecorationLayer doNotExport\" aria-hidden=\"true\"><\/div><div class=\"outputLayer scrollableOutputDecorationLayer doNotExport\" aria-hidden=\"true\"><\/div><div class=\"outputLayer navigationFocusLayer doNotExport\" aria-hidden=\"false\" tabindex=\"-1\" role=\"application\" aria-label=\"figure output \"><\/div><\/div><\/div><\/div><\/div><div  style = 'margin: 10px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(33, 33, 33); font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><span>I modified Edgar's <\/span><span style=' font-family: monospace;'>plotDirectedGraph<\/span><span> function to animate the creation of the graph.<\/span><\/div><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(33, 33, 33); font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><img class = \"imageNode\" src = \"https:\/\/blogs.mathworks.com\/pick\/files\/potw_countLetters_2.gif\" width = \"700\" height = \"526\" alt = \"countletters_anim2.gif\" style = \"vertical-align: baseline; width: 700px; height: 526px;\"><\/img><\/div><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(33, 33, 33); font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><span>Give this a try and leave a <\/span><a href = \"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/172905-countlettersnum#reviews_tab\"><span>comment<\/span><\/a><span> for Edgar.<\/span><\/div>\n<\/div><script type=\"text\/javascript\">var css = '.eoOutputWrapper { width: calc(90vw - 10px) !important; }'; var head = document.head || document.getElementsByTagName('head')[0], style = document.createElement('style'); head.appendChild(style); style.type = 'text\/css'; if (style.styleSheet){ style.styleSheet.cssText = css; } else { style.appendChild(document.createTextNode(css)); }<\/script>","protected":false},"excerpt":{"rendered":"<div class=\"overview-image\"><img decoding=\"async\"  class=\"img-responsive\" src=\"https:\/\/blogs.mathworks.com\/pick\/files\/potw_countLetters_1.png\" onError=\"this.style.display ='none';\" \/><\/div><p>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.Start with a number between 1 and... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/pick\/2024\/10\/01\/visualizing-number-of-letters-in-a-number\/\">read more >><\/a><\/p>","protected":false},"author":35,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[16],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/16706"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/users\/35"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/comments?post=16706"}],"version-history":[{"count":1,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/16706\/revisions"}],"predecessor-version":[{"id":16709,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/16706\/revisions\/16709"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/media?parent=16706"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/categories?post=16706"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/tags?post=16706"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}