Loading multiple files with similar filenames

조회 수: 5 (최근 30일)
Mary
Mary 2013년 6월 10일
(Sorry for asking another question so soon!)
I'm working on loading 8 files with similar names from one directory into a for loop which grabs data from each of them and then resaves them as one file.
Example
%Open directory
files = dir(uigetdir,'.mat*')
%Run this through all of the files in the directory
for i= 1:numel(files)
%load one of the files
load files(i)
%Determine information from the files
fileName=files(i).name;
a=regexp(fileName,'_','split')
experimentName = a{2}
participantName = a{3}
block=regexp(a{4},'\d*')
type = a{5}
%Load other files which have similar information to the previous file
for i = numel(files)
if regexp(fileName, 'experimentName') > 0
load files(i)
%run code on all 8 files in a for loop
for n=1:8
end
%save new information
end
%re-run on next set of 8 similar files for 200+ sets of data
I just feel like I'm going about loading these in all the wrong way. I think I may be setting myself up to have things rerun over themselves way more than they need to.
Is there a better way for me to load all 8 files with a similar name at once, such that when I finish processing them MATLAB knows to grab a different set that does not repeat any of the files from the previous set?
  댓글 수: 1
Jan
Jan 2013년 6월 10일
I do not understand the question. Do you mean "load(files(i).name)" insteda of "load files(i)"? "for i = numel(files)" is the same as "i = numel(files)".

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Variables에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by