Loading .Mat Files in Nested Sub folders using Dir
1 次查看(过去 30 天)
显示 更早的评论
I'm working on a project where I need to pull files from this expansive directory with many subfolders nested in folders.
I'm a complete novice when it comes to using matlab and directories, and I was wondering if anyone could help get me started!
I've been using mainFolder = dir(fullfile(uigetfile)) to open the original main directory and then grabbing other folders using more fullfile and wildcards for things they contain. I just don't know how many sub_folders MATLAB will open and let me edit
I've written in english essentially what I need the code to accomplish - I'm not expecting someone to write this for me, just provide me with tips on how to get started!
%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... Thanks,
ML
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 File Operations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!