【问题标题】:MATLAB: Opening and Editing Files nested in folders in foldersMATLAB:打开和编辑嵌套在文件夹中的文件
【发布时间】:2013-06-03 21:37:51
【问题描述】:

我正在处理一个项目,我需要从这个扩展目录中提取文件,其中许多子文件夹嵌套在文件夹中。

在使用 matlab 和目录方面,我是一个完全的新手,我想知道是否有人可以帮助我入门!

我一直在使用 mainFolder = dir(fullfile(uigetfile)) 打开原来的主目录 然后使用更多完整文件和通配符获取其他文件夹以获取它们包含的内容。我只是不知道 MATLAB 会打开多少子文件夹让我编辑

我基本上已经用英语写了我需要代码来完成的内容 - 我不希望有人为我写这个,只是为我提供如何开始的提示!

%function getvariables

%open mainFolder

%open "dates" %name of subfolder in mainFolder

%open "experiment" %name of subfolder in dates

%open "analysis" %name of subfolder in experiment

 if .mat filename includes the string pre
     % pull variables from the .mat file
     % figure out if it contains a certain string of numbers ex. 1234
 if .mat filename includes the string post
     % pull other variables from the .mat file
     % figure out if it contains a certain string of numbers ex. 1234
 else
     % pull other stuff
     % figure out if it contains a certain string of numbers ex. 1234
 end

%load .mat file with the same numbers ex. 1234.mat from ANOTHER folder

%add the variables I grabbed from the pre/post/else .mat files to the loaded 1234.mat file

%save the newly updated 1234.mat file

%run this for a hundred or so different files...

谢谢,

机器学习

【问题讨论】:

    标签: matlab for-loop directory matlab-load mat-file


    【解决方案1】:

    查看子目录!在文件交换上,它是一个很棒的功能,可以返回所有文件夹和扩展子文件夹中的所有文件,并且您可以按扩展名过滤文件名等等。

    http://www.mathworks.com/matlabcentral/fileexchange/15859-subdir-a-recursive-file-search

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-06-22
      • 2020-12-03
      • 1970-01-01
      • 2015-01-19
      • 1970-01-01
      • 1970-01-01
      • 2016-04-11
      相关资源
      最近更新 更多