{"id":11727,"date":"2020-09-18T18:14:32","date_gmt":"2020-09-18T22:14:32","guid":{"rendered":"https:\/\/blogs.mathworks.com\/pick\/?p=11727"},"modified":"2020-09-26T10:32:04","modified_gmt":"2020-09-26T14:32:04","slug":"r2020b","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/pick\/2020\/09\/18\/r2020b\/","title":{"rendered":"R2020b"},"content":{"rendered":"<div xmlns:mwsh=\"http:\/\/www.mathworks.com\/namespace\/mcode\/v1\/syntaxhighlight.dtd\" class=\"content\">\r\n   <introduction>\r\n      <p><a href=\"http:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/3208495\">Sean<\/a>'s pick this week is <a href=\"https:\/\/www.mathworks.com\/downloads\">MATLAB R2020b<\/a> by MathWorks Development.\r\n      <\/p>\r\n   <\/introduction>  \r\n   <p>Our fall 2020 release shipped this week.  Today, I'll go over some of my favorite convenience features.  You can read the full <a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2020b\/matlab\/release-notes.html\">release notes here<\/a>.\r\n   <\/p>\r\n   <p>First and foremost - <tt>fileparts<\/tt> is vectorized now!!!  This has been a longstanding wish:\r\n   <\/p><pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">\r\n[p,f,ext] = fileparts(fullfile(pwd, [<span style=\"color: #A020F0\">\"hello.m\"<\/span>, <span style=\"color: #A020F0\">\"world.fig\"<\/span>]))<\/pre><pre style=\"font-style:oblique\">p = \r\n  1&times;2 string array\r\n    \"C:\\Documents\\MATLAB\\potw\\R2020b\"    \"C:\\Documents\\MATLAB\\potw\\R2020b\"\r\nf = \r\n  1&times;2 string array\r\n    \"hello\"    \"world\"\r\next = \r\n  1&times;2 string array\r\n    \".m\"    \".fig\"\r\n<\/pre><p>If you want your function accept a file or folder, you can use <tt>mustBeFile<\/tt> and <tt>mustBeFolder<\/tt> as validators in an arguments block and it will validate that they exist. You'll also get tab-complete of file or folder names for free.\r\n   <\/p><pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\"><span style=\"color: #0000FF\">arguments<\/span>\r\n    filename <span style=\"color: #B28C00\"> (1, 1) string {mustBeFile}<\/span>\r\n<span style=\"color: #0000FF\">end<\/span><\/pre><p>Have you ever wanted to read the lines of a text file and used either fileread which returns a long character vector or fgetl yourself?  Well now you can use <a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2020b\/matlab\/ref\/readlines.html\"><tt>readlines<\/tt><\/a>!\r\n   <\/p><pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">t = readlines(<span style=\"color: #A020F0\">'mainR2020b.m'<\/span>);\r\nt(1:4)<\/pre><pre style=\"font-style:oblique\">ans = \r\n  4&times;1 string array\r\n    \"%% R2020b\"\r\n    \"%\"\r\n    \"% &lt;http:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/3208495 Sean&gt;'s\"\r\n    \"% pick this week is\"\r\n<\/pre><p>XML reading and writing has also always been a challenge.  You can now read and write XML files with <a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2020b\/matlab\/ref\/readstruct.html\"><tt>readstruct<\/tt><\/a> or <a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2020b\/matlab\/ref\/writestruct.html\"><tt>writestruct<\/tt><\/a>.\r\n   <\/p><pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">s = imfinfo(<span style=\"color: #A020F0\">'cameraman.tif'<\/span>);\r\nwritestruct(s, <span style=\"color: #A020F0\">'cameraman.xml'<\/span>);<\/pre><p>In the app building world, you can now set the Icon for the uifigure to a custom one, and <a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2020b\/matlab\/ref\/exportapp.html\">export (print) the app<\/a>.\r\n   <\/p><pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">uifigure(<span style=\"color: #A020F0\">\"Icon\"<\/span>, <span style=\"color: #A020F0\">\"HawaiiFlower.jpg\"<\/span>, <span style=\"color: #A020F0\">\"Name\"<\/span>, <span style=\"color: #A020F0\">\"Custom Icon Figure\"<\/span>)<\/pre><p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/pick\/files\/customicon.png\"> <\/p>\r\n   <h3>Comments<a name=\"6\"><\/a><\/h3>\r\n   <p>Give it a try and let us know what you think <a href=\"http:\/\/blogs.mathworks.com\/pick\/?p=11727#respond\">here<\/a>.\r\n   <\/p><script language=\"JavaScript\">\r\n<!--\r\n\r\n    function grabCode_952720465aa14620bc3c4a3e2e2fa02e() {\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='952720465aa14620bc3c4a3e2e2fa02e ' + '##### ' + 'SOURCE BEGIN' + ' #####';\r\n        t2='##### ' + 'SOURCE END' + ' #####' + ' 952720465aa14620bc3c4a3e2e2fa02e';\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        author = 'Sean de Wolski';\r\n        copyright = 'Copyright 2020 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 author and copyright lines at the bottom if specified.\r\n        if ((author.length > 0) || (copyright.length > 0)) {\r\n            d.writeln('');\r\n            d.writeln('%%');\r\n            if (author.length > 0) {\r\n                d.writeln('% _' + author + '_');\r\n            }\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      \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_952720465aa14620bc3c4a3e2e2fa02e()\"><span style=\"font-size: x-small;        font-style: italic;\">Get \r\n            the MATLAB code \r\n            <noscript>(requires JavaScript)<\/noscript><\/span><\/a><br><br>\r\n      Published with MATLAB&reg; R2020b<br><\/p>\r\n<\/div>\r\n<!--\r\n952720465aa14620bc3c4a3e2e2fa02e ##### SOURCE BEGIN #####\r\n%% R2020b\r\n%\r\n% <http:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/3208495 Sean>'s\r\n% pick this week is\r\n% <https:\/\/www.mathworks.com\/downloads\r\n% MATLAB R2020b> by MathWorks Development.\r\n% \r\n\r\n%% \r\n% Our fall 2020 release shipped this week.  Today, I'll go over some of my\r\n% favorite convenience features.  You can read the full\r\n% <https:\/\/www.mathworks.com\/help\/releases\/R2020b\/matlab\/release-notes.html\r\n% release notes here>.\r\n%\r\n% First and foremost - |fileparts| is vectorized now!!!  This has been a\r\n% longstanding wish:\r\n%\r\n\r\n!code\r\n[p,f,ext] = fileparts(fullfile(pwd, [\"hello.m\", \"world.fig\"]))\r\n\r\n%%\r\n% If you want your function accept a file or folder, you can use mustBeFile\r\n% and mustBeFolder as validators in an arguments block and it will validate\r\n% that they exist. You'll also get tab-complete for free\r\n% \r\n%   arguments\r\n%       filename (1, 1) string {mustBeFile}\r\n%   end\r\n% \r\n%% \r\n%\r\n% Have you ever wanted to read the lines of a text file and used either\r\n% fileread which returns a long character vector or fgetl yourself?  Well\r\n% now you can use\r\n% <https:\/\/www.mathworks.com\/help\/releases\/R2020b\/matlab\/ref\/readlines.html\r\n% |readlines|>!\r\n\r\nt = readlines('mainR2020b.m');\r\nt(1:4)\r\n\r\n%%\r\n% XML reading and writing has also always been a challenge.  You can now\r\n% read and write XML files with\r\n% <https:\/\/www.mathworks.com\/help\/releases\/R2020b\/matlab\/ref\/readstruct.html\r\n% |readstruct|> or\r\n% <https:\/\/www.mathworks.com\/help\/releases\/R2020b\/matlab\/ref\/writestruct.html\r\n% |writestruct|>.\r\n%\r\n\r\ns = imfinfo('cameraman.tif');\r\nwritestruct(s, 'cameraman.xml');\r\n\r\n%%\r\n% In the app building world, you can now set the Icon for the uifigure to a\r\n% custom one, and\r\n% <https:\/\/www.mathworks.com\/help\/releases\/R2020b\/matlab\/ref\/exportapp.html\r\n% export (print) the app>.\r\n%\r\n%   uifigure(\"Icon\", \"HawaiiFlower.jpg\", \"Name\", \"Custom Icon Figure\")\r\n%\r\n% <<customicon.png>>\r\n\r\n%% Comments\r\n% \r\n% Give it a try and let us know what you think\r\n% <http:\/\/blogs.mathworks.com\/pick\/?p=11727#respond here>.\r\n%\r\n \r\n\r\n##### SOURCE END ##### 952720465aa14620bc3c4a3e2e2fa02e\r\n-->","protected":false},"excerpt":{"rendered":"<div class=\"overview-image\"><img decoding=\"async\"  class=\"img-responsive\" src=\"https:\/\/blogs.mathworks.com\/pick\/files\/customicon.png\" onError=\"this.style.display ='none';\" \/><\/div><p>\r\n   \r\n      Sean's pick this week is MATLAB R2020b by MathWorks Development.\r\n      \r\n     \r\n   Our fall 2020 release shipped this week.  Today, I'll go over some of my favorite convenience... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/pick\/2020\/09\/18\/r2020b\/\">read more >><\/a><\/p>","protected":false},"author":87,"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\/11727"}],"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\/87"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/comments?post=11727"}],"version-history":[{"count":5,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/11727\/revisions"}],"predecessor-version":[{"id":11741,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/11727\/revisions\/11741"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/media?parent=11727"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/categories?post=11727"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/tags?post=11727"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}