Loading multiple files with similar filenames

3 visualizaciones (últimos 30 días)
Mary
Mary el 10 de Jun. de 2013
(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 comentario
Jan
Jan el 10 de Jun. de 2013
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)".

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre File Operations en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by