For loop based on files names and locations
Ältere Kommentare anzeigen
Hi,
Im trying to run first level analysis for many participants. I got the code from spm12 for one participants and now I'm trying to run for-loop to repeat the analysis to all other participants. I'd really appriciate that if I could have any suggestions about how to define for-loop based on the directory and the names of the files (the files names are different). The data is organized in one folder that includes a folder for each participant and that folder includes the file (along with other files).
Thank you!
Antworten (2)
KSSV
am 15 Dez. 2022
% get the folder contents
d = dir() ;
% remove all files (isdir property is 0)
dfolders = d([d(:).isdir]) ;
% remove '.' and '..'
dfolders = dfolders(~ismember({dfolders(:).name},{'.','..'})) ;
% loop for each folder
for i = 1:length(dfolders)
dfolders.name
end
Kategorien
Mehr zu Programming finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!