MATLAB: How to find recursively all the paths and files beyond the working directory in MATLAB

filefindMATLABpath

I want to find all paths and files which are under my working directory. That is all paths and files for example under the working path $MATLABROOT\work\myexample
For example the function should return something similar to what is shown below:
$MATLABROOT\work\test.m
$MATLABROOT\work\test2.m
$MATLABROOT\work\test.xls
$MATLABROOT\...
and all the paths under $MATLABROOT

Best Answer

The ability to find all the paths and files under the working directory is not available in MATLAB.
To work around this issue, you can use a function in MATLAB Central File Exchange. The function is called SUBDIR and is written by Elmar Tarajan. Even if there are newer versions of this function this one is optimized in code and you will get also all the files listed:
<http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=1492&objectType=file http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=1492&objectType=file>
Note: The files of MATLAB Central File Exchange will not be supported by The Mathworks. These are files written by MATLAB Users for MATLAB users. If you have troubles with these functions please ask directly the author for help.