I have just started learning Matlab and I wrote a script for analysis which seems to work! :) Now, at the beginning of my script, I want to create a loop, to loop over all participants (46 participants, divided into 23 dyads) and conditions (2 conditions: ES and NS), using the sprintf function. I just can't seem to figure it out..
Fyi, this means that I have 4 files for every dyad (both conditions for both participants) and my files are named as follows (for clarity, I give all four):
- '003S' indicates the first subject and '004L' indicates the second subject of the dyad (so this concerns the dyad consisting of subject 3 and subject 4)
- ES/NS indicates the condition
- 'sub_1' indicates that this is the data from the first subject of the dyad ('003S') and 'sub_2' indicates that this is the data from the second subject of the dyad ('004S')
Now, I want to create a loop to loop over all dyads and both conditions (and put the rest of my code within this loop), but I get stuck (I am mainly confused because I perform the rest of my analysis separately for the participants within a dyad, but the loop has to go over the dyads and not separate participants.). This is what I have so far:
dyads = 1:23
conditions = 1:2
% number of conditions = 1:2
for i = 1:23, ii = 1:2
filename = sprintf('dyad%d_condition%d',dyads(i), conditions(ii)); % the filename I specify here must manipulate the string with filename used in pop_loadset
data_sub_A = pop_loadset('filename','hyper_cleaned_SNS_003S_004L_E_ES_sub_1.set','check','off','loadmode','info');
data_sub_B = pop_loadset('filename','hyper_cleaned_SNS_003S_004L_E_ES_sub_2.set','check','off','loadmode','info');
I'm sorry for all this text! Any help would be greatly appreciated, thanks!!