1

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

在使用 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...

谢谢,

机器学习

4

1 回答 1

1

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

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

于 2013-06-07T18:15:44.620 回答