{"id":4464,"date":"2021-05-04T07:00:10","date_gmt":"2021-05-04T11:00:10","guid":{"rendered":"https:\/\/blogs.mathworks.com\/steve\/?p=4464"},"modified":"2021-05-13T17:30:41","modified_gmt":"2021-05-13T21:30:41","slug":"how-to-run-blog-post-code-in-your-browser","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/steve\/2021\/05\/04\/how-to-run-blog-post-code-in-your-browser\/","title":{"rendered":"How to Run Blog Post Code in Your Browser"},"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(0, 0, 0); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><span>I have published more than 560 blog posts here since 2006, and I estimate that about 98% of them started out as MATLAB scripts.<\/span><\/div><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(0, 0, 0); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><span>Recently, I've started writing my blog posts as <\/span><a href = \"https:\/\/www.mathworks.com\/help\/matlab\/live-scripts-and-functions.html\"><span>live scripts<\/span><\/a><span>. Live scripts contain not only MATLAB code, but also code output, graphics output, and formatted text, including equations. It's a really nice way to share a technical story.<\/span><\/div><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(0, 0, 0); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><span>Now, thanks to my friends on the MATLAB Central development team, I can write a blog post as a live script -- and then you can run the code yourself in your web browser!<\/span><\/div><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(0, 0, 0); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><span>Let me show you how it works. Here is my <\/span><a href = \"https:\/\/blogs.mathworks.com\/steve\/2021\/05\/13\/how-to-use-a-custom-interpolation-kernel-with-imresize\/\"><span>blog post on using a custom interpolation kernel with imresize<\/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(0, 0, 0); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><img class = \"imageNode\" src = \"https:\/\/blogs.mathworks.com\/steve\/files\/run_in_browser_1.png\" width = \"600\" height = \"493\" alt = \"imresize-post-a.png\" style = \"vertical-align: baseline\"><\/img><\/div><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(0, 0, 0); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><span>Now scroll all the down to the bottom of the post (above the comments):<\/span><\/div><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(0, 0, 0); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><img class = \"imageNode\" src = \"https:\/\/blogs.mathworks.com\/steve\/files\/run_in_browser_2.png\" width = \"600\" height = \"428\" alt = \"imresize-post-b.png\" style = \"vertical-align: baseline\"><\/img><\/div><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(0, 0, 0); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><span>Click on the \"Run in your browser\" button, and you'll get your own MATLAB Online session in your browser, with the contents of the live script preloaded for you. It will look something like this:<\/span><\/div><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(0, 0, 0); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><img class = \"imageNode\" src = \"https:\/\/blogs.mathworks.com\/steve\/files\/run_in_browser_3.png\" width = \"600\" height = \"461\" alt = \"run-in-browser.png\" style = \"vertical-align: baseline\"><\/img><\/div><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(0, 0, 0); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><span>Alternatively, you can click on the \"Download Live Script\" button to download the code to your own computer.<\/span><\/div><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(0, 0, 0); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><span>For access to MATLAB and Simulink in your web browser whenever you have internet access, just head over to <\/span><a href = \"https:\/\/matlab.mathworks.com\/\"><span>MATLAB Online<\/span><\/a><span>.<\/span><\/div>\r\n<\/div><script type=\"text\/javascript\">var css = ''; 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><a href=\"https:\/\/blogs.mathworks.com\/steve\/files\/run_in_browser.mlx\"><button class=\"btn btn-sm btn_color_blue pull-right add_margin_10\">Download Live Script<\/button><\/a>","protected":false},"excerpt":{"rendered":"<div class=\"overview-image\"><img src=\"https:\/\/blogs.mathworks.com\/steve\/files\/run_in_browser_3.png\" class=\"img-responsive attachment-post-thumbnail size-post-thumbnail wp-post-image\" alt=\"\" decoding=\"async\" loading=\"lazy\" \/><\/div><p>I have published more than 560 blog posts here since 2006, and I estimate that about 98% of them started out as MATLAB scripts.Recently, I've started writing my blog posts as live scripts. Live... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/steve\/2021\/05\/04\/how-to-run-blog-post-code-in-your-browser\/\">read more >><\/a><\/p>","protected":false},"author":42,"featured_media":4510,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/posts\/4464"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/users\/42"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/comments?post=4464"}],"version-history":[{"count":4,"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/posts\/4464\/revisions"}],"predecessor-version":[{"id":4514,"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/posts\/4464\/revisions\/4514"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/media\/4510"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/media?parent=4464"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/categories?post=4464"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/tags?post=4464"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}