Loading multiple non-sequential .mat files to automate a code?
1 回表示 (過去 30 日間)
古いコメントを表示
Hi there! I'm very new to MatLab and am trying to figure out how to automate a code I have written. I have a set of data that is named by date and in different folders (i.e. folder names are 20171202_mic, 20171204_mic, etc. and file names things like green1_20171202_mic_data). I have seen how to automate code that has more sequential names, but I was wondering if it was possible to automate the code without the sequential naming scheme.
So far, I have named the path to the shared folder, then named the list of files with the individual foldername\name of file (i.e. '\20171202_mic\green1_20171202_16404_mic_data')
then I have for k=1:length(listoffiles)
load(fullfile(path, listoffiles{k}))
Am I very off base with this? Is there a way to do this?
Any help is very much appreciated!
0 件のコメント
採用された回答
Julie
2018 年 8 月 20 日
listoffiles = dir('D:\Data\**\*.mat')
for k=1:length(listoffiles)
CurFile=listoffiles(k)
load([CurFile.folder,'\\', CurFile.name])
end
This gets you a list of all the files ending in .mat (change if your data has a different extension) and then loads them into matlab. Also replace the "D:\Data" with the path-name of the main folder.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Environment and Settings についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!