There's no such functionality built in.
You could build a dependency tree of your main function by using depfun
with mfilename
.
depfun(mfilename())
will return a list of all functions/m-files that are called by the currently executing m-file.
This will include all files that come as MATLAB builtins, you might want to remove those (and only record the MATLAB version in your excel sheet).
As pseudocode:
% get all files:
dependencies = depfun(mfilename());
for all dependencies:
if not a matlab-builtin:
copyfile(dependency, your_folder)
As a "long term" solution you might want to check if using a version control system like subversion, mercurial (or one of many others) would be applicable in your case. In larger projects this is preferred way to record the version of source code used to produce a certain result.