{"id":244,"date":"2008-08-11T10:07:11","date_gmt":"2008-08-11T15:07:11","guid":{"rendered":"https:\/\/blogs.mathworks.com\/desktop\/2008\/08\/11\/olympic-fever\/"},"modified":"2016-04-03T15:28:38","modified_gmt":"2016-04-03T19:28:38","slug":"olympic-fever","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/community\/2008\/08\/11\/olympic-fever\/","title":{"rendered":"Olympic fever"},"content":{"rendered":"<p>Watching the Olympics opening ceremonies, I&#8217;m reminded of my very first MATLAB program. I was a beleaguered freshman in a scientific computation class for which I did not meet the prerequisites. The first problem set was a warm-up to get used to doing assignments using MATLAB-files. To test our <tt>plot<\/tt> skills, the professor had us plot Olympic rings in a figure window.<\/p>\n<p>It was an interesting challenge &#8211; learning trig functions, the subtleties of <tt>plot<\/tt>, and the twist of interlocking rings of different colors. Unfortunately, I did not start archiving my assignments until my sophomore year, so I don&#8217;t have that original M-file to share. Here is an unelegant, non-vectorized replica that I came up with today. I&#8217;m sure <a href=\"https:\/\/blogs.mathworks.com\/loren\">Loren<\/a> could come up with something more clever, but it is a fun thing to do and in the spirit of the times.<\/p>\n<div align=\"center\"><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/desktop\/michael_katz_olympics\/rings.jpg\" alt=\"five rings\" border=\"0\" \/><\/div>\n<div class=\"content\">\n<pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid #c8c8c8;\"><span style=\"color: #228b22;\">%rings.m plots olympic rings<\/span>\r\nN = 100;\r\nangle = linspace(pi\/4,9*pi\/4,N); <span style=\"color: #228b22;\">%all the way around<\/span>\r\n\r\n<span style=\"color: #228b22;\">% Make the x and y's for each of the five circles<\/span>\r\nxb = cos(angle) * 0.9;\r\nyb = sin(angle) * 0.9;\r\n\r\nxy = cos(angle) * 0.9 + 1;\r\nyy = sin(angle) * 0.9 - 1;\r\n\r\nxk = cos(angle) * 0.9 + 2;\r\nyk = sin(angle) * 0.9;\r\n\r\nxg = cos(angle) * 0.9 + 3;\r\nyg = sin(angle) * 0.9 - 1;\r\n\r\nxr = cos(angle) * 0.9 + 4;\r\nyr = sin(angle) * 0.9;\r\n\r\n<span style=\"color: #228b22;\">% Make the Figure<\/span>\r\nfigure\r\nhold <span style=\"color: #a020f0;\">on<\/span>\r\nplot(xb(1:3*N\/4),yb(1:3*N\/4),<span style=\"color: #a020f0;\">'b'<\/span>,<span style=\"color: #a020f0;\">'linewidth'<\/span>,10);\r\nplot(xy(N\/4:N),yy(N\/4:N),<span style=\"color: #a020f0;\">'y'<\/span>,<span style=\"color: #a020f0;\">'linewidth'<\/span>,10)\r\n\r\nplot(xk(1:3*N\/4),yk(1:3*N\/4),<span style=\"color: #a020f0;\">'k'<\/span>,<span style=\"color: #a020f0;\">'linewidth'<\/span>,10);\r\nplot(xy(1:N\/4),yy(1:N\/4),<span style=\"color: #a020f0;\">'y'<\/span>,<span style=\"color: #a020f0;\">'linewidth'<\/span>,10);\r\nplot(xb(3*N\/4:end),yb(3*N\/4:end),<span style=\"color: #a020f0;\">'b'<\/span>,<span style=\"color: #a020f0;\">'linewidth'<\/span>,10);\r\n\r\nplot(xr(1:N\/2),yr(1:N\/2),<span style=\"color: #a020f0;\">'r'<\/span>,<span style=\"color: #a020f0;\">'linewidth'<\/span>,10);\r\nplot(xg(1:N),yg(1:N),<span style=\"color: #a020f0;\">'g'<\/span>,<span style=\"color: #a020f0;\">'linewidth'<\/span>,10);\r\n\r\nplot(xk(3*N\/4:N),yk(3*N\/4:N),<span style=\"color: #a020f0;\">'k'<\/span>,<span style=\"color: #a020f0;\">'linewidth'<\/span>,10);\r\nplot(xr(N\/2:N),yr(N\/2:N),<span style=\"color: #a020f0;\">'r'<\/span>,<span style=\"color: #a020f0;\">'linewidth'<\/span>,10);\r\n\r\n<span style=\"color: #228b22;\">%make the axis pretty<\/span>\r\naxis <span style=\"color: #a020f0;\">equal<\/span>\r\naxis <span style=\"color: #a020f0;\">off<\/span>\r\nset(gca,<span style=\"color: #a020f0;\">'XLim'<\/span>,[-1.2 5.2])\r\nset(gcf,<span style=\"color: #a020f0;\">'Color'<\/span>,[1 1 1])<\/pre>\n<\/div>\n<p>What does this have to do with the desktop? Well, not much. I thought I&#8217;d come up with some gold-medal metaphor, but nothing uncontrived comes to mind. Instead I&#8217;ll leave you with a request for MATLAB programs analyzing olympic results, or even better, predicting olympic results. To get started, I recommend using <tt>urlread<\/tt> with an updated results site.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Watching the Olympics opening ceremonies, I&#8217;m reminded of my very first MATLAB program. I was a beleaguered freshman in a scientific computation class for which I did not meet the&#8230; <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/community\/2008\/08\/11\/olympic-fever\/\">read more >><\/a><\/p>\n","protected":false},"author":38,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/posts\/244"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/users\/38"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/comments?post=244"}],"version-history":[{"count":2,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/posts\/244\/revisions"}],"predecessor-version":[{"id":3398,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/posts\/244\/revisions\/3398"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/media?parent=244"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/categories?post=244"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/tags?post=244"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}