-
Notifications
You must be signed in to change notification settings - Fork 0
/
savedata.m
37 lines (32 loc) · 984 Bytes
/
savedata.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
function [] = savedata(fid, answer, trial, cue, target , ReactionTime, keyPressed)
id = str2num(answer{1});
age = str2num(answer{2});
hand = answer{3};
gender = answer{4};
rt = round(ReactionTime * 1000);
%response = 0 if no key was pressed
%response = 1 if Key = LeftArrow
%response = 2 if Key = RightArrow
response = 0;
if strcmp(keyPressed, 'LeftArrow') == 1
response = 1;
elseif strcmp(keyPressed, 'RightArrow') == 1
response = 2;
end
%trialtype : valid/invalid/neutral
%0 = neutral (uncued), 1=valid(cued), 2=invalid(cued)
trialType = 2;
if cue == target
trialType = 1;
elseif cue == 0
trialType = 0;
end
%accuracy
accuracy = 0;
if response == target
accuracy = 1;
end
fprintf(fid, '%d %d %s %s %d %d %d %d %d %d %d \n' , ...
id, age, hand, gender, trial, cue, target, ...
trialType, response, rt, accuracy);
end