For loop based on files names and locations
3 views (last 30 days)
Show older comments
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!
Answers (2)
KSSV
on 15 Dec 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
0 Comments
See Also
Categories
Find more on Startup and Shutdown in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!