Excel Values Different from MatLab
1 回表示 (過去 30 日間)
古いコメントを表示
The Excel Value I calculated through the program is valued differently from the results from MatLab.
If you look at the attached file, I am trying to calculate the average correct value and average latency depending on the type.
Overall Accuracy - Average accuracy of all trials EXCEPT those with a latency of 0
Overall Latency - Average latency of all trials whose "Correct" value is equal to 1
NonTarget Accuracy - Average Accuracy of all trials EXCEPT those with a latency of 0 AND that belong to either "Type" 11 or 22
NonTarget Latency - Average latency of all trials whose "Correct" value is equal to 1 AND that belong to either "Type" 11 or 22
Target Accuracy - Average Accuracy of all trials EXCEPT those with a latency of 0 AND that belong to either "Type" 33 or 44
Target Latency - Average latency of all trials whose "Correct" value is equal to 1 AND that belong to either "Type" 33 or 44
The code I used is as follows:
id = 'SubjectID';
path = '(Path folder containing files)';
%Input subject file.
filename = [path id 'N2B1.dat'];
delimiter = ' ';
%North Chamber = start at 21. South Chamber = start at 22.
startRow = 22;
formatSpec = '%f%f%f%f%f%s%[^\n\r]';
fileID = fopen(filename,'r');
dataArray = textscan(fileID, formatSpec, 'Delimiter', delimiter, 'MultipleDelimsAsOne', true, 'HeaderLines' ,startRow-1, 'ReturnOnError', false);
fclose(fileID);
tab1 = table(dataArray{1:end-1}, 'VariableNames', {'Trial','Resp','Type','Correct','Latency','StimResp'});
clearvars filename delimiter startRow formatSpec fileID dataArray ans;
%to merge the two files
tabm = vertcat(tab1);
clc
%Delete extra rows generated by STIM responses
toDelete = tabm.Type<5;
tabm(toDelete,:) = [];
size(tabm);
%Code for omissions
tabm.Omiss = zeros(size(tabm.Type));
tabm.Omiss(tabm.Latency==3000 & tabm.Correct==0) = 1;
%Code for comissions
tabm.Comiss = tabm.Correct;
tabm.Comiss(tabm.Correct==1) = 0;
tabm.Comiss(tabm.Correct==0) = 1;
tabm.Omiss(tabm.Latency==3000 & tabm.Correct==0) = 1;
%Code target & non-target
%Recode a new variable (Cond) as 1 = target and 2 = non-target
tabm.Cond = tabm.Type;
tabm.Cond(tabm.Cond==33) = 1;
tabm.Cond(tabm.Cond==44) = 1;
tabm.Cond(tabm.Cond==11) = 2;
tabm.Cond(tabm.Cond==22) = 2;
%Calculate Performance Stuff.
OverallAcc = mean(tabm.Correct)*100;
OverallRT = mean(tabm.Latency(tabm.Correct==1));
NonTargetAcc = mean(tabm.Correct(tabm.Cond==2))*100;
TargetAcc = mean(tabm.Correct(tabm.Cond==1))*100;
NonTargetRT = mean(tabm.Latency(tabm.Correct==1 & tabm.Cond==2));
TargetRT = mean(tabm.Latency(tabm.Correct==1 & tabm.Cond==1));
OverallRT_std = std(tabm.Latency(tabm.Correct==1));
NonTargetRT_std = std(tabm.Latency(tabm.Correct==1 & tabm.Cond==1));
TargetRT_std = std(tabm.Latency(tabm.Correct==1 & tabm.Cond==2));
%Calculate Coefficient of Variation (Std / Reaction Time)
OverallCV = (OverallRT_std/OverallRT);
NonTargetCV = (NonTargetRT_std/NonTargetRT);
TargetCV = (TargetRT_std/TargetRT);
output = table(OverallAcc, OverallRT, OverallCV, TargetAcc, TargetRT, TargetCV, NonTargetAcc, NonTargetRT, NonTargetCV);
0 件のコメント
回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Data Import from MATLAB についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!