Looping a script over several files

1 view (last 30 days)
Tomas
Tomas on 9 Dec 2013
Commented: dpb on 9 Dec 2013
Hi gang,
I'm trying to combine several files of data from an eye tracking experiment into one file. We have two files per condition per participant with three conditions, so a total of 6 files per participant.
The files are in different folders and are named either valuepair_AB001_a or valuepair_AB001_a_fix where AB001 is the participant ID and the a at the end signifies the condition (we have similar files for conditions b and c for each participant).
I wrote a quick script to combine the values I need for one condition from 1 participant, but now I need to loop it over all the other files. I would also like to make it so that each row of data has the participants condition/participant ID on it as well.
I don't have the slightest idea how I would go about doing that, but if anyone can point me in the right direction, it would be very much appreciated.
Thanks for your help and let me know if you need any clarification!
  1 Comment
dpb
dpb on 9 Dec 2013
Basically, just use dir for each of the subdirectories and then loop over the returned structures processing each in turn, simply doing a comparison of the subject name to get the correct one for each iteration. Presuming you don't have missing files, the length() of each directory listing should be the same if the structure is as I think I understand you said.

Sign in to comment.

Answers (0)

Categories

Find more on File Operations 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!