MATLAB: How to work around depfun(bar) bug: Matlab 64bit 2012B, on win7

2012b64bitdepfunMATLAB

  • Background: I'm using matlab to perform some data processing in an academic environment. The code for the analysis receives frequent tweaks and changes.
  • Goal: I'd like the main processing function to save copies of all the user functions called during the analysis alongside the processed files, as a record of what was done in that specific iteration of the analysis. the function 'depfun' seems ideal for this purpose, all I need to do is filter out the dependencies that are in the matlab toolboxes and I have a list of the user functions which I can then copy over to my output folder.
  • Problem: One of the things the analysis does is generate and save some bar charts using the 'bar' function. When depfun reaches bar it seems to go into an infinite loop and never returns. ctrl+c fails to stop the process and I must force-quit matlab. This prevents retrieval of any of the dependencies using depfun. This problem exists whether bar is called within one of the dependency functions, or whether depfun(bar) is called directly. I am using Matlab 2012b 64bit on windows 7.
  • Question: Is there a workaround for this error, or a way to generate a dependency list that ignores functions from the matlab toolboxes so that I don't encounter it? *I tried the depsubfun function from the matlab exchange with similar results
Thanks

Best Answer

depfun takes ages to search the sub-directories of matlabroot. There are several(?) depfun replacements in the FEX, which avoids files belonging to the Matlab installation. They use
list = depfun(func,'-toponly','-quiet');
recursively on the users directories. See:
depsubfun is older (MATLAB 7.0.1 (R14SP1), 2005) than the poor performance of depfun (if I am not mistaken). It doesn't use the toponly keyword
f = depfun(CS{i},'-quiet');