view .m files in a folder (including subFolders) in MATLAB

浪尽此生 提交于 2019-12-13 07:17:10

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!