问题
I have a Folder Factors
inside Project
folder. (all inside MyDocuments/Matlab). I need the list of all .m files in the folder FACTORS. Factors has subFolders and these subFolders hold all the .m files. Any suggestions?
Directory Design ->
Project...
Factors ... etc
subFol1 (has .m files)
subFol2 (has .m files)
...
回答1:
I have solved a similar problem.On Windows platforms, ,Like this:
pathName='.... \FACTORS';%your path
[stat path]=dos(['dir ' pathName '\*.m /s /B >path.txt'] );
name=importdata('path.txt');
delete path.txt
Now,you can see all files which matches the conditions is in the cell array "Name"
回答2:
This function would be useful. It will recursively search folders, executing a user defined function on each directory. You will need to write your own function to list all .m files in the current directory.
来源:https://stackoverflow.com/questions/8673736/view-m-files-in-a-folder-including-subfolders-in-matlab