How to save input in loop without overwriting?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
The code below take input from the categories of every participant, in every block and every trial. The problem is the same information is taken in these three categories meaning it will end up overwriting the information. Although, I have seen similar forms of this question I asked, I feel that most other codes do not seem to have as much of a need to record information in the same variable as my code.
Currently the loops work fine showing different clips but when it comes to saving responses of valence on a 1-7 likert scale, this is not working. I mainly want to make the valence 1-7 information for 30 participants, in 4 blocks, with 5-9 trials per block depending on the block to be recorded and saved, but, very importantly in a way that they do not overwrite the previous information.
I have tried the idea of the code below so that the number of the subject changes each time meaning valence info for difference subjects saves in different places but even with this the blocks but this has not worked well.
Any ideas about this?
numTrials = numTrialInBlock(block);))
TrialsPerBlock = [7, 5, 7, 9];
Blocks=4
s.(sprintf('valence_subject_num%d', valence, NumTrials, TrialsPerBlock, Blocks)
subjectnum=input('Please enter subject number: ');
Condition=input('Please enter your condition: ');
s_num=int2str(subjectnum);
numblocks=2;
for block=1:numblocks
numTrials = numTrialInBlock(block);
%**************************************************************************************************************************************
% Begin trial loop
for trial=1:numtrials
set = 'ABCDEFHGI';
if(highload==1)
set = set(randperm(length(set)));
end
cgflip(1,1,1)
cgpencol(0,0,0);
preparestring(set(1),0,-200,0);
preparestring(set(2),0,-150,0);
preparestring(set(3),0,-100,0);
preparestring(set(4),0,-50,0);
preparestring(set(5),0,0,0);
preparestring(set(6),0,50,0);
preparestring(set(7),0,100,0);
preparestring(set(8),0,150,0);
preparestring(set(9),0,200,0);
cgflip
wait(2000);
cgflip(1,1,1)
cgpencol(0,0,0);
cgdraw(-size,0,size,0)
cgdraw(0,-size,0,size)
cgflip
wait(1200);
cgflip(1,1,1)
wait(100);
clipName = sprintf('./video_clips/Trauma_Clip_%d_%d.avi', block,trial);
clipWidth = 720;
clipHeight = 567;
PlayClip(clipName, clipWidth, clipHeight);
cgflip
waitkeydown(inf,71);
cgflip(1,1,1);
preparestring('Please rate the valence of the clip you just saw.',0,0,200);
valence = input('Use the keyboard keys labelled 1 to 7 to choose your rating. ');
loadpict('valence.bmp',1, 0, 0, 650, 150);
s.(sprintf('valence_subject_num%d', valence))
cgflip
Response = waitkeydown(inf,28:34);
cgflip(1,1,1);
end
header['', 'subjectnum, condition', 'valence', 'arousal', 'rt', 'accuracy']
xlswrite('study_results', header ,'sheet2', 'B2')
1 Kommentar
Walter Roberson
am 3 Jul. 2015
I think maybe the English word you are looking for is 'violence' rather than 'valence'.
Antworten (1)
Darsana Thulasi
am 6 Jul. 2015
You can try to create a structure for the variable response. It could look like this:
Response.(Participant_name).{blockno}(trial)
0 Kommentare
Siehe auch
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!