{"id":448,"date":"2011-03-14T16:24:26","date_gmt":"2011-03-14T16:24:26","guid":{"rendered":"https:\/\/blogs.mathworks.com\/desktop\/2011\/03\/14\/sharing-figures-with-friends\/"},"modified":"2011-03-14T16:24:26","modified_gmt":"2011-03-14T16:24:26","slug":"sharing-figures-with-friends","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/community\/2011\/03\/14\/sharing-figures-with-friends\/","title":{"rendered":"Sharing Figures with Friends"},"content":{"rendered":"<p>MATLAB Mobile has a neat feature that allows you to e-mail a saved figure snapshot as a PNG file, with just two taps! You can try it out: from a snapshot in the History tab or an individual interactive figure in the Figures tab, just tap the action button in the upper-right. <\/p>\n<div align=\"center\">\n<img decoding=\"async\" border=\"0\" src=\"https:\/\/blogs.mathworks.com\/images\/desktop\/michael_katz_email_figure\/email_figure_mm.png\" alt=\"Steps to email a snapshot in MATLAB Mobile\">\n<\/div>\n<p>This is a neat feature, but what if you don't have MATLAB Mobile? Wouldn't it be great if you an email a figure image right from MATLAB? Of course you can! MATLAB has a handy <a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2010b\/techdoc\/ref\/sendmail.html\"><tt>sendmail<\/tt><\/a> function that uses your email SMTP server to send an email with attachments. I've most commonly seen this function used to email the results after a long simulation or to send nightly reports, but it can also be used to send pictures. <\/p>\n<p>Using <tt>sendmail<\/tt>'s attachment functionality combined with the magical <a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2010b\/techdoc\/ref\/print.html\"><tt>print<\/tt><\/a> function, in two steps we can save a figure to disk and then attach it to an outgoing email. In the following code we use the current figure <tt>gcf<\/tt> but any figure handle can be supplied. <\/p>\n<pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">print(gcf,<span style=\"color: #A020F0\">'-dpng'<\/span>,<span style=\"color: #A020F0\">'-r0'<\/span>,<span style=\"color: #A020F0\">'figure.png'<\/span>)\r\nsendmail(<span style=\"color: #A020F0\">'my.friend@example.com'<\/span>,<span style=\"color: #A020F0\">'Look at this cool figure'<\/span>,<span style=\"color: #A020F0\">'Hey man, check out what I did with MATLAB!'<\/span>,<span style=\"color: #A020F0\">'figure.png'<\/span>)<\/pre>\n<p>The one gotcha is that is that <tt>sendmail<\/tt> requires a one-time set-up of your email account. The details for setting the server and username are in the <a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2010b\/techdoc\/ref\/sendmail.html\"\">sendmail documentation<\/a>.<\/p>\n<p>Now that I think about it, \"Figures with Friends\" sounds like a good idea for my next mobile app. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>MATLAB Mobile has a neat feature that allows you to e-mail a saved figure snapshot as a PNG file, with just two taps! You can try it out: from a snapshot in the History tab or an individual... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/community\/2011\/03\/14\/sharing-figures-with-friends\/\">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":[54,39],"tags":[103,102,104],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/posts\/448"}],"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=448"}],"version-history":[{"count":0,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/posts\/448\/revisions"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/media?parent=448"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/categories?post=448"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/tags?post=448"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}