"Data variables must be numeric or logical" despite variable being logical when using grpstats
Ältere Kommentare anzeigen
function ViewData(data)
resp = cell2mat(data(:, 3)) == 39;
corrAns = ismember(data(:, 1), {'2F_H', '2F_V'});
score = double(corrAns == resp);
ifi = cell2mat(data(:, 2));
orient2 = ismember(data(:,1), {'1F_H', '2F_H'});
tblData = table(score, ifi, data(:, 1), orient2, 'variablenames', {'score', 'ifi', 'trialType', 'orient2'});
% tblData = table(score, ifi, orient, data(:, 1), 'variablenames', {'score', 'ifi', 'trialType'});
tblMean = grpstats(tblData, {'orient2', 'ifi'}); %change trialType to orient, or vice versa
disp(tblMean);
end
So the error is "Error using dsgrpstats (line 293) Data variables must be numeric or logical."
But I'm confused because orient2 is literally a logical, no? If I define tblMean in this way, however, it works:
tblData = table(score, ifi, data(:, 1), orient2, 'variablenames', {'score', 'ifi', 'trialType', 'orient2'});
% tblData = table(score, ifi, orient, data(:, 1), 'variablenames', {'score', 'ifi', 'trialType'});
tblMean = grpstats(tblData, {'trialType','orient2', 'ifi'});
and the column for orient2 LITERALLY is "true" or "false" all the way down. AND when I do class(tblData.trialType), it's "cell" which adds even more to the confusion.
I'm sure it's a simple fix but I can't see it. Thank you!
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Get Started with MATLAB finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!