{"id":2720,"date":"2010-06-17T17:39:35","date_gmt":"2010-06-17T16:39:35","guid":{"rendered":"http:\/\/www.walkingrandomly.com\/?p=2720"},"modified":"2010-06-17T17:39:35","modified_gmt":"2010-06-17T16:39:35","slug":"matlab-says-hi","status":"publish","type":"post","link":"https:\/\/walkingrandomly.com\/?p=2720","title":{"rendered":"MATLAB says &#8220;Hi&#8221;"},"content":{"rendered":"<p>One of the <a href=\"https:\/\/www.walkingrandomly.com\/?p=19\">earliest posts<\/a> I made on Walking Randomly (almost 3 years ago now &#8211; how time flies!) described the following equation and gave a plot of it in Mathematica.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/walkingrandomly.com\/wp-content\/ql-cache\/quicklatex.com-2ac85801055712ffb81affb35811a019_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\"&#92;&#108;&#105;&#103;&#104;&#116;&#32;&#102;&#40;&#120;&#44;&#121;&#41;&#61;&#101;&#94;&#123;&#45;&#120;&#94;&#50;&#45;&#92;&#102;&#114;&#97;&#99;&#123;&#121;&#94;&#50;&#125;&#123;&#50;&#125;&#125;&#32;&#92;&#99;&#111;&#115;&#32;&#40;&#52;&#32;&#120;&#41;&#43;&#101;&#94;&#123;&#45;&#51;&#92;&#108;&#101;&#102;&#116;&#40;&#40;&#120;&#43;&#48;&#46;&#53;&#41;&#94;&#50;&#43;&#92;&#102;&#114;&#97;&#99;&#123;&#121;&#94;&#50;&#125;&#123;&#50;&#125;&#92;&#114;&#105;&#103;&#104;&#116;&#41;&#125;&#32;\" title=\"Rendered by QuickLaTeX.com\" height=\"37\" width=\"344\" style=\"vertical-align: -4px;\"\/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.walkingrandomly.com\/images\/mathematica\/hi.jpg\" alt=\"\" width=\"360\" height=\"269\" align=\"middle\" \/><\/p>\n<p>Some time later I followed this up with<a href=\"https:\/\/www.walkingrandomly.com\/?p=64\"> another blog post and a Wolfram Demonstration<\/a>.<\/p>\n<p>Well, <a href=\"http:\/\/stackoverflow.com\/questions\/3020220\/plotting-hi-in-matlab\">over at Stack Overflow,<\/a> some people have been rendering this cool equation using MATLAB. Here&#8217;s the first version<\/p>\n<pre>x = linspace(-3,3,50);\r\ny = linspace(-5,5,50);\r\n[X Y]=meshgrid(x,y);\r\nZ = exp(-X.^2-Y.^2\/2).*cos(4*X) + exp(-3*((X+0.5).^2+Y.^2\/2));\r\nZ(Z&gt;0.001)=0.001;\r\nZ(Z&lt;-0.001)=-0.001;\r\nsurf(X,Y,Z);\r\ncolormap(flipud(cool))\r\nview([1 -1.5 2])<\/pre>\n<p><img decoding=\"async\" src=\"https:\/\/www.walkingrandomly.com\/images\/matlab\/hi1_matlab.png\" alt=\"\" align=\"middle\" \/><\/p>\n<p>and here&#8217;s the second.<\/p>\n<pre>[x y] = meshgrid( linspace(-3,3,50), linspace(-5,5,50) );\r\nz = exp(-x.^2-0.5*y.^2).*cos(4*x) + exp(-3*((x+0.5).^2+0.5*y.^2));\r\nidx = ( abs(z)&gt;0.001 );\r\nz(idx) = 0.001 * sign(z(idx)); \r\n\r\nfigure('renderer','opengl')\r\npatch(surf2patch(surf(x,y,z)), 'FaceColor','interp');\r\nset(gca, 'Box','on', ...\r\n    'XColor',[.3 .3 .3], 'YColor',[.3 .3 .3], 'ZColor',[.3 .3 .3], 'FontSize',8)\r\ntitle('$e^{-x^2 - \\frac{y^2}{2}}\\cos(4x) + e^{-3((x+0.5)^2+\\frac{y^2}{2})}$', ...\r\n    'Interpreter','latex', 'FontSize',12) \r\n\r\nview(35,65)\r\ncolormap( [flipud(cool);cool] )\r\ncamlight headlight, lighting phong<\/pre>\n<p><img decoding=\"async\" src=\"https:\/\/www.walkingrandomly.com\/images\/matlab\/hi2_matlab.jpg\" alt=\"\" align=\"middle\" \/><\/p>\n<p>Do you have any cool graphs to share?<\/p>\n","protected":false},"excerpt":{"rendered":"<p>One of the earliest posts I made on Walking Randomly (almost 3 years ago now &#8211; how time flies!) described the following equation and gave a plot of it in Mathematica. Some time later I followed this up with another blog post and a Wolfram Demonstration. Well, over at Stack Overflow, some people have been [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[6,4,8,11],"tags":[],"class_list":["post-2720","post","type-post","status-publish","format-standard","hentry","category-general-math","category-math-software","category-mathematica","category-matlab"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p3swhs-HS","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=\/wp\/v2\/posts\/2720","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2720"}],"version-history":[{"count":11,"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=\/wp\/v2\/posts\/2720\/revisions"}],"predecessor-version":[{"id":2731,"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=\/wp\/v2\/posts\/2720\/revisions\/2731"}],"wp:attachment":[{"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2720"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2720"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2720"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}