Loading multiple non-sequential .mat files to automate a code?

1 回表示 (過去 30 日間)
Clarice Diebold
Clarice Diebold 2018 年 8 月 20 日
コメント済み: Clarice Diebold 2018 年 8 月 21 日
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!

採用された回答

Julie
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.
  1 件のコメント
Clarice Diebold
Clarice Diebold 2018 年 8 月 21 日
Thank you so so much for your help!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeEnvironment and Settings についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by