MATLAB: Can anyone please explain me this line of a code

arrayfun

probability = arrayfun(@(x) mean(audR(audR(:,1)==x,2)==2) , contrast);

Best Answer

If audR is a matrix, then
audR(audR(:,1)==x,2)==2
% ^^^^^^^^^ % first column of audR
% ^^^ % ... is equal to x.
% ^^^^^^^^^^^^ % used as a logical index into the rows of audR
% ^ % second column of audR
% ^^^ % ... is equal to 2.
So the code takes the rows of audR where the first column equals x, and checks if their second column equals 2.