【问题标题】:view .m files in a folder (including subFolders) in MATLAB在 MATLAB 中查看文件夹(包括子文件夹)中的 .m 文件
【发布时间】:2012-01-30 05:14:21
【问题描述】:

我在Project 文件夹内有一个文件夹Factors。 (全部在 MyDocuments/Matlab 中)。我需要 FACTORS 文件夹中所有 .m 文件的列表。 Factors 有子文件夹,这些子文件夹包含所有 .m 文件。有什么建议吗?

目录设计->

Project...
    Factors ... etc
       subFol1 (has .m files)
       subFol2 (has .m files)
    ...

【问题讨论】:

  • 你用的是windows还是matlab?

标签: file matlab directory subdirectory dir


【解决方案1】:

我已经解决了类似的问题。在Windows平台上,像这样:

pathName='.... \FACTORS';%your path
[stat path]=dos(['dir ' pathName '\*.m /s /B >path.txt'] );
name=importdata('path.txt');
delete path.txt

现在,您可以看到所有符合条件的文件都在单元格数组“名称”中

【讨论】:

    【解决方案2】:

    This 函数会很有用。它将递归搜索文件夹,在每个目录上执行用户定义的函数。您需要编写自己的函数来列出当前目录中的所有 .m 文件。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-12-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-07-05
      相关资源
      最近更新 更多