{"id":3154,"date":"2012-01-20T08:54:00","date_gmt":"2012-01-20T13:54:00","guid":{"rendered":"https:\/\/blogs.mathworks.com\/pick\/?p=3154"},"modified":"2012-01-20T08:54:00","modified_gmt":"2012-01-20T13:54:00","slug":"publishing-called-functions","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/pick\/2012\/01\/20\/publishing-called-functions\/","title":{"rendered":"Publishing called functions"},"content":{"rendered":"<div xmlns:mwsh=\"https:\/\/www.mathworks.com\/namespace\/mcode\/v1\/syntaxhighlight.dtd\" class=\"content\">\r\n   <p><a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/15007\">Jiro<\/a>'s pick this week is <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/33476-publish-dependent-and-called-functions\">\"Publish dependent and called functions\"<\/a> by <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/116098\">Nick Angelini<\/a>.\r\n   <\/p>\r\n   <p><a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2011b\/techdoc\/matlab_env\/f6-22451.html\">Publishing<\/a> is one of the things I always highlight to MATLAB users, new or experienced. Even though the feature has been around for\r\n      over 7 years, not many people know about it. I was one of those people who went through graduate school manually creating\r\n      reports from figures generated in MATLAB. Now, publishing is something that I can't live without. Even many of the bloggers\r\n      (myself included) on MATLAB Central use <a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2011b\/techdoc\/ref\/publish.html\"><tt>publish<\/tt><\/a> to write the blog posts.\r\n   <\/p>\r\n   <p>I was pretty excited to see this entry by Nick. I've always wanted to make something like this, but I never got around to\r\n      implementing it. While <tt>publish<\/tt> would only generate a report for the function or the script you specify, <tt>publishdepfun<\/tt> will generate separate reports for any user-defined functions used in the main file, and even append the report to the end\r\n      of the main report. I immediately found one of my demos that I show at seminars and published it. The syntax is pretty much\r\n      identical to the MATLAB's <tt>publish<\/tt> command. You can also pass in the options structure that's accepted by <tt>publish<\/tt>.\r\n   <\/p><pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">publishdepfun(<span style=\"color: #A020F0\">'MainAnalysis'<\/span>);<\/pre><p>My <tt>MainAnalysis.m<\/tt> script had 3 custom functions: <tt>createFit.m<\/tt>, <tt>createfigure.m<\/tt>, and <tt>importfile.m<\/tt>. Those 3 functions were published as well and were appended to the end of the main report. As you can see below, the report\r\n      has a section called \"Called Functions\".\r\n   <\/p>\r\n   <p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/jiro\/potw_publishdepfun\/publishdepfun_screenshot.PNG\"> <\/p>\r\n   <p><b>Comments<\/b><\/p>\r\n   <p>He states in entry that there are still some limitations, but I think this is a great start and has plenty of good utility.\r\n      Let us know what you think <a href=\"https:\/\/blogs.mathworks.com\/pick\/?p=3154#respond\">here<\/a> or leave a <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/33476-publish-dependent-and-called-functions#comments\">comment<\/a> for Nick.\r\n   <\/p><script language=\"JavaScript\">\r\n<!--\r\n\r\n    function grabCode_c2e211b4717d4a858707784b1d41fcfd() {\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='c2e211b4717d4a858707784b1d41fcfd ' + '##### ' + 'SOURCE BEGIN' + ' #####';\r\n        t2='##### ' + 'SOURCE END' + ' #####' + ' c2e211b4717d4a858707784b1d41fcfd';\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 = 'Jiro Doke';\r\n        copyright = 'Copyright 2012 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_c2e211b4717d4a858707784b1d41fcfd()\"><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; 7.13<br><\/p>\r\n<\/div>\r\n<!--\r\nc2e211b4717d4a858707784b1d41fcfd ##### SOURCE BEGIN #####\r\n%%\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/15007\r\n% Jiro>'s pick this week is\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/33476-publish-dependent-and-called-functions \"Publish\r\n% dependent and called functions\"> by\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/116098 Nick\r\n% Angelini>.\r\n%\r\n% <https:\/\/www.mathworks.com\/help\/releases\/R2011b\/techdoc\/matlab_env\/f6-22451.html\r\n% Publishing> is one of the things I always highlight to MATLAB users, new\r\n% or experienced. Even though the feature has been around for over 7 years,\r\n% not many people know about it. I was one of those people who went through\r\n% graduate school manually creating reports from figures generated in\r\n% MATLAB. Now, publishing is something that I can't live without. Even many\r\n% of the bloggers (myself included) on MATLAB Central use\r\n% <https:\/\/www.mathworks.com\/help\/releases\/R2011b\/techdoc\/ref\/publish.html |publish|> to\r\n% write the blog posts.\r\n%\r\n% I was pretty excited to see this entry by Nick. I've always wanted to\r\n% make something like this, but I never got around to implementing it.\r\n% While |publish| would only generate a report for the function or the\r\n% script you specify, |publishdepfun| will generate separate reports for\r\n% any user-defined functions used in the main file, and even append the\r\n% report to the end of the main report. I immediately found one of my demos\r\n% that I show at seminars and published it. The syntax is pretty much\r\n% identical to the MATLAB's |publish| command. You can also pass in the\r\n% options structure that's accepted by |publish|.\r\n\r\npublishdepfun('MainAnalysis');\r\n\r\n%%\r\n% My |MainAnalysis.m| script had 3 custom functions: |createFit.m|,\r\n% |createfigure.m|, and |importfile.m|. Those 3 functions were published as\r\n% well and were appended to the end of the main report. As you can see\r\n% below, the report has a section called \"Called Functions\".\r\n%\r\n% <<publishdepfun_screenshot.PNG>>\r\n%\r\n% *Comments*\r\n%\r\n% He states in entry that there are still some limitations, but I think\r\n% this is a great start and has plenty of good utility. Let us know what\r\n% you think <https:\/\/blogs.mathworks.com\/pick\/?p=3154#respond here> or leave\r\n% a <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/33476-publish-dependent-and-called-functions#comments\r\n% comment> for Nick.\r\n\r\n##### SOURCE END ##### c2e211b4717d4a858707784b1d41fcfd\r\n-->","protected":false},"excerpt":{"rendered":"<p>\r\n   Jiro's pick this week is \"Publish dependent and called functions\" by Nick Angelini.\r\n   \r\n   Publishing is one of the things I always highlight to MATLAB users, new or experienced. Even though... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/pick\/2012\/01\/20\/publishing-called-functions\/\">read more >><\/a><\/p>","protected":false},"author":35,"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\/3154"}],"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\/35"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/comments?post=3154"}],"version-history":[{"count":8,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/3154\/revisions"}],"predecessor-version":[{"id":3164,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/3154\/revisions\/3164"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/media?parent=3154"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/categories?post=3154"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/tags?post=3154"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}