{"id":2931,"date":"2011-09-30T13:26:15","date_gmt":"2011-09-30T13:26:15","guid":{"rendered":"https:\/\/blogs.mathworks.com\/pick\/2011\/09\/30\/determine-file-dependencies\/"},"modified":"2017-01-06T21:32:57","modified_gmt":"2017-01-07T02:32:57","slug":"determine-file-dependencies","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/pick\/2011\/09\/30\/determine-file-dependencies\/","title":{"rendered":"Determine File Dependencies"},"content":{"rendered":"<div xmlns:mwsh=\"https:\/\/www.mathworks.com\/namespace\/mcode\/v1\/syntaxhighlight.dtd\" class=\"content\">\r\n   <introduction><\/introduction>\r\n   <p><a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/911\">Brett<\/a>'s Pick this week is <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/17291-fdep--a-pedestrian-function-dependencies-finder\">\"FDEP: a pedestrian function dependencies finder,\"<\/a> by <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/4309\">Us<\/a>.\r\n   <\/p>\r\n   <p>Back in September, 2009, I <a href=\"https:\/\/blogs.mathworks.com\/pick\/2009\/09\/18\/easier-and-less-error-prone-creation-of-zip-files\/\">featured<\/a> a file called <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/10702-exporttozip--identifies-the-dependencies-of-an-m-file-and-creates-a-zip-file\">exportToZip<\/a> that facilitates easy creation of Zip files. I'm still a fan of <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/21286\">Malcolm's<\/a> submission; I use it frequently.\r\n   <\/p>\r\n   <p>Today's Pick facilitates the same functionality, plus more. FDEP \"dissects [MATLAB] files and iteratively looks for all user-defined\r\n      functions used during runtime.\" With a simple syntax:\r\n   <\/p>\r\n   <p>fd = fdep('MorphTool.m')<\/p>\r\n   <p>you get a structure that shows a wealth of useful information. If you really want to dig in and detect all file dependencies\r\n      for you MATLAB function, function <a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2011b\/techdoc\/ref\/depfun.html\">DEPFUN<\/a> does a pretty good job--but can be very slow. Us's file is a wrapper around DEPFUN, but \"due to an efficient pruning engine,\"\r\n      it can be much faster.\r\n   <\/p>\r\n\r\n   <p>Output from depfun is a structure that includes information about Toolbox dependencies, function calls, help, subfunctions,\r\n      and more. To create a complete zip file, for example, one could say simply:\r\n   <\/p><pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">zip(<span style=\"color: #A020F0\">'myZip'<\/span>,fd.fun);<\/pre><p>Us's code is, as usual, difficult (for me, at least) to read, but superbly implemented and robust--I've learned to trust it\r\n      over the years.\r\n   <\/p>\r\n   <p>As always, <a href=\"https:\/\/blogs.mathworks.com\/pick\/?p=2931#respond\">comments to this blog post<\/a> are welcome. Or leave a comment for Us <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/17291-fdep--a-pedestrian-function-dependencies-finder#comments\">here<\/a>.\r\n   <\/p><script language=\"JavaScript\">\r\n<!--\r\n\r\n    function grabCode_76b13a70ad154e9e8f82c0d7b599eae2() {\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='76b13a70ad154e9e8f82c0d7b599eae2 ' + '##### ' + 'SOURCE BEGIN' + ' #####';\r\n        t2='##### ' + 'SOURCE END' + ' #####' + ' 76b13a70ad154e9e8f82c0d7b599eae2';\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 = 'Brett Shoelson';\r\n        copyright = 'Copyright 2011 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_76b13a70ad154e9e8f82c0d7b599eae2()\"><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\n76b13a70ad154e9e8f82c0d7b599eae2 ##### SOURCE BEGIN #####\r\n%% Determine File Dependencies\r\n%% \r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/911 Brett>'s Pick this week is\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/17291-fdep--a-pedestrian-function-dependencies-finder \"FDEP: a pedestrian function dependencies finder,\"> by \r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/4309 Us>.\r\n\r\n%%\r\n% Back in September, 2009, I <https:\/\/blogs.mathworks.com\/pick\/2009\/09\/18\/easier-and-less-error-prone-creation-of-zip-files\/ featured> a file called\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/10702-exporttozip--identifies-the-dependencies-of-an-m-file-and-creates-a-zip-file exportToZip> \r\n% that facilitates easy creation of Zip files. I'm still a\r\n% fan of\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/21286 Malcolm's>\r\n% submission; I use it frequently. \r\n\r\n%%\r\n% Today's Pick facilitates the same functionality, plus\r\n% more. FDEP \"dissects [MATLAB] files and iteratively looks\r\n% for all user-defined functions used during runtime.\" With\r\n% a simple syntax:\r\n\r\n%%\r\n% fd = fdep('MorphTool.m')\r\n\r\n%%\r\n% you get a structure that shows a wealth of useful\r\n% information. If you really want to dig in and detect all\r\n% file dependencies for you MATLAB function, function <https:\/\/www.mathworks.com\/help\/releases\/R2011b\/techdoc\/ref\/depfun.html DEPFUN> \r\n% does a pretty good jobREPLACE_WITH_DASH_DASHbut can be very slow. Us's file is\r\n% a wrapper around DEPFUN, but \"due to an efficient pruning\r\n% engine,\" it can be much faster. \r\n\r\n%%\r\n% \r\n% <<https:\/\/www.mathworks.com\/matlabcentral\/fx_files\/17291\/8\/fdepimg.png>>\r\n% \r\n\r\n%%\r\n% Output from depfun is a structure that includes\r\n% information about Toolbox dependencies, function calls,\r\n% help, subfunctions, and more. To create a complete zip\r\n% file, for example, one could say simply:\r\n\r\n%%\r\nzip('myZip',fd.fun);\r\n\r\n%% \r\n% Us's code is, as usual, difficult (for me, at least) to read, but superbly\r\n% implemented and robustREPLACE_WITH_DASH_DASHI've learned to trust it over the years. \r\n\r\n%% \r\n% As always, <https:\/\/blogs.mathworks.com\/pick\/?p=2931#respond comments to this blog post> are welcome. Or leave a\r\n% comment for Us <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/17291-fdep--a-pedestrian-function-dependencies-finder#comments here>.\r\n##### SOURCE END ##### 76b13a70ad154e9e8f82c0d7b599eae2\r\n-->","protected":false},"excerpt":{"rendered":"<p>\r\n   \r\n   Brett's Pick this week is \"FDEP: a pedestrian function dependencies finder,\" by Us.\r\n   \r\n   Back in September, 2009, I featured a file called exportToZip that facilitates easy creation of... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/pick\/2011\/09\/30\/determine-file-dependencies\/\">read more >><\/a><\/p>","protected":false},"author":34,"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\/2931"}],"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\/34"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/comments?post=2931"}],"version-history":[{"count":1,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/2931\/revisions"}],"predecessor-version":[{"id":8342,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/2931\/revisions\/8342"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/media?parent=2931"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/categories?post=2931"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/tags?post=2931"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}