Finding the percentage of correct responses
2 views (last 30 days)
Show older comments
Hello,
I'm relatively new to MATLAB so still trying to learn the basics.
In my problem, I have one matrix (1000x2) which contains information on the stimuli number and which emotion each stimuli presents (eg 7 for neutral, 6 for angry etc). My other matrix (4627x9) contains 1 participant's responses, the stimuli number presented per trial is in column 1 and their chosen emotion category for each facial expression they are presented with is in column 7.
How would I find the percentage of correct responses between these matrices? ie for each time a neutral face is presented (coded as 7) how often does the participant correctly select this expression (coded as 7).
Apologies if this question is confusing, I'm still getting to grips with MATLAB.
Any help is much appreciated.
Thanks, Shannon
2 Comments
dpb
on 13 Jul 2016
Probably simpler to explain the data if you were to present a (very) small subsection that illustrates which is what...
But, basically, for the given stimulus, find the indices of the corresponding data and use those to retrieve the necessary values. Or, depending on the structure, you may find simply logical addressing works easier. There are also functions
doc intersect % and friends
that may be of interest...
Tucker
on 13 Jul 2016
it looks like you may not have matching data sets: If I understand your data arrangement you should have the same number of rows in both your key matrix, and your subject response matrix, and column1 of both should be the trial number. Right now you say you have 4627 responses, but only 1000 keys, so there is no way to assign correct or false to all the subject responses. If for some reason you have presentations with no key for the correct value and you need to look ONLY at the subset of presentations where you have a key, you can try something like this:
%find the indices where presentation numbers in the key appear in the responses:
[~,idxKey,idxResponse]=intersect(keyMatrix(:,1),responseMatrix(:,1));
%now use the indexes for the key to make a key vector only containing the key entries that match a response:
key=keyMatrix(idxKey,2);
%now use the response index variable make a response vector that corresponds to the key vector
response=responseMatrix(idxResponse,7);
%now get a vector of 0/1 which is 1 where the subject made a correct response:
isCorrect=key==response;
%now see how many total correct responses we have:
numCorrect=sum(isCorrect);
%and convert that into a percent:
pctCorrect=numCorrect/numel(key);
after this you should be able to continue as I suggested before. I tried to expand this into multiple lines so that it was easy to follow, but this all could be written compactly in about 3 lines with nested calls. I also didn't test this, so there may be a couple of minor errors to correct before you get it running. Using intersect the way I did above should work fine as long as the presentation number in the responseMatrix is unique. If the same number can appear multiple times in either the keyMatrix or responseMatrix, then using intersect the way I did above won't work.
Answers (0)
See Also
Categories
Find more on Entering Commands in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!