{"id":6679,"date":"2016-03-18T09:00:53","date_gmt":"2016-03-18T13:00:53","guid":{"rendered":"https:\/\/blogs.mathworks.com\/pick\/?p=6679"},"modified":"2017-08-27T20:04:16","modified_gmt":"2017-08-28T00:04:16","slug":"visualizing-fourier-series","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/pick\/2016\/03\/18\/visualizing-fourier-series\/","title":{"rendered":"Visualizing Fourier Series"},"content":{"rendered":"\r\n<div class=\"content\"><p><a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/15007\">Jiro<\/a>'s pick this week is <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/49533-fourier-series-animation-using-harmonic-circles\">Harmonic Circles Animation<\/a> by <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/2651313\">Mehmet E. Yavuz<\/a>.<\/p><p>Continuing on from my previous post, <a href=\"https:\/\/blogs.mathworks.com\/pick\/2016\/03\/04\/bouncing-ball-animation-using-events-with-ode\/\">Bouncing Ball Animation<\/a>, here's another great example of using animation to illustrate mathematical concepts. In this example by Mehmet, a <a href=\"https:\/\/en.wikipedia.org\/wiki\/Fourier_series\">Fourier series<\/a> is illustrated using circles. The first animation shows the first few terms individually, and the second animation shows the sum of the terms.<\/p><p>\r\n<video controls> <source src=\"https:\/\/blogs.mathworks.com\/images\/pick\/jiro\/potw_fourier_animation\/fourier_animation_video.mp4\" type=\"video\/mp4\">Your browser does not support the video tag.<\/video>\r\n<\/p><p>I have one suggestion for improvement in his code. In order to create the animation, Mehmet re-plots the graphics inside a for-loop. A more efficient, and recommended, way is to plot once and only update the X and Y data of the graphics objects inside the loop. <\/p><p><b>Comments<\/b><\/p><p>How do you use animations to convey ideas? Let us know what you think <a href=\"https:\/\/blogs.mathworks.com\/pick\/?p=6679#respond\">here<\/a> or leave a <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/49533-fourier-series-animation-using-harmonic-circles#comments\">comment<\/a> for Mehmet.<\/p><script language=\"JavaScript\"> <!-- \r\n    function grabCode_167b67b9d84f44e882b4328fdef31d96() {\r\n        \/\/ Remember the title so we can use it in the new page\r\n        title = document.title;\r\n\r\n        \/\/ Break up these strings so that their presence\r\n        \/\/ in the Javascript doesn't mess up the search for\r\n        \/\/ the MATLAB code.\r\n        t1='167b67b9d84f44e882b4328fdef31d96 ' + '##### ' + 'SOURCE BEGIN' + ' #####';\r\n        t2='##### ' + 'SOURCE END' + ' #####' + ' 167b67b9d84f44e882b4328fdef31d96';\r\n    \r\n        b=document.getElementsByTagName('body')[0];\r\n        i1=b.innerHTML.indexOf(t1)+t1.length;\r\n        i2=b.innerHTML.indexOf(t2);\r\n \r\n        code_string = b.innerHTML.substring(i1, i2);\r\n        code_string = code_string.replace(\/REPLACE_WITH_DASH_DASH\/g,'--');\r\n\r\n        \/\/ Use \/x3C\/g instead of the less-than character to avoid errors \r\n        \/\/ in the XML parser.\r\n        \/\/ Use '\\x26#60;' instead of '<' so that the XML parser\r\n        \/\/ doesn't go ahead and substitute the less-than character. \r\n        code_string = code_string.replace(\/\\x3C\/g, '\\x26#60;');\r\n\r\n        copyright = 'Copyright 2016 The MathWorks, Inc.';\r\n\r\n        w = window.open();\r\n        d = w.document;\r\n        d.write('<pre>\\n');\r\n        d.write(code_string);\r\n\r\n        \/\/ Add copyright line at the bottom if specified.\r\n        if (copyright.length > 0) {\r\n            d.writeln('');\r\n            d.writeln('%%');\r\n            if (copyright.length > 0) {\r\n                d.writeln('% _' + copyright + '_');\r\n            }\r\n        }\r\n\r\n        d.write('<\/pre>\\n');\r\n\r\n        d.title = title + ' (MATLAB code)';\r\n        d.close();\r\n    }   \r\n     --> <\/script><p style=\"text-align: right; font-size: xx-small; font-weight:lighter;   font-style: italic; color: gray\"><br><a href=\"javascript:grabCode_167b67b9d84f44e882b4328fdef31d96()\"><span style=\"font-size: x-small;        font-style: italic;\">Get \r\n      the MATLAB code <noscript>(requires JavaScript)<\/noscript><\/span><\/a><br><br>\r\n      Published with MATLAB&reg; R2016a<br><\/p><p class=\"footer\"><br>\r\n      Published with MATLAB&reg; R2016a<br><\/p><\/div><!--\r\n167b67b9d84f44e882b4328fdef31d96 ##### SOURCE BEGIN #####\r\n%%\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/15007\r\n% Jiro>'s pick this week is\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/49533-fourier-series-animation-using-harmonic-circles Harmonic\r\n% Circles Animation> by\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/2651313 Mehmet E.\r\n% Yavuz>.\r\n%\r\n% Continuing on from my previous post,\r\n% <https:\/\/blogs.mathworks.com\/pick\/2016\/03\/04\/bouncing-ball-animation-using-events-with-ode\/\r\n% Bouncing Ball Animation>, here's another great example of using animation\r\n% to illustrate mathematical concepts. In this example by Mehmet, a\r\n% <https:\/\/en.wikipedia.org\/wiki\/Fourier_series Fourier series> is\r\n% illustrated using circles. The first animation shows the first few terms\r\n% individually, and the second animation shows the sum of the terms.\r\n%\r\n% <html>\r\n% <video controls> <source src=\"https:\/\/blogs.mathworks.com\/images\/pick\/jiro\/potw_fourier_animation\/fourier_animation_video.mp4\" type=\"video\/mp4\">Your browser does not support the video tag.<\/video>\r\n% <\/html>\r\n%\r\n% I have one suggestion for improvement in his code. In order to create the\r\n% animation, Mehmet re-plots the graphics inside a for-loop. A more\r\n% efficient, and recommended, way is to plot once and only update the X and\r\n% Y data of the graphics objects inside the loop.\r\n% <https:\/\/www.mathworks.com\/help\/matlab\/creating_plots\/animation-techniques.html\r\n% This page> explains the technique in detail.\r\n%\r\n% *Comments*\r\n%\r\n% How do you use animations to convey ideas? Let us know what you think\r\n% <https:\/\/blogs.mathworks.com\/pick\/?p=6679#respond here> or leave a\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/49533-fourier-series-animation-using-harmonic-circles#comments\r\n% comment> for Mehmet.\r\n\r\n##### SOURCE END ##### 167b67b9d84f44e882b4328fdef31d96\r\n-->","protected":false},"excerpt":{"rendered":"<p>\r\nJiro's pick this week is Harmonic Circles Animation by Mehmet E. Yavuz.Continuing on from my previous post, Bouncing Ball Animation, here's another great example of using animation to illustrate... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/pick\/2016\/03\/18\/visualizing-fourier-series\/\">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\/6679"}],"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=6679"}],"version-history":[{"count":4,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/6679\/revisions"}],"predecessor-version":[{"id":8836,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/6679\/revisions\/8836"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/media?parent=6679"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/categories?post=6679"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/tags?post=6679"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}