MATLAB: Select corresponding values out of different columns of a matrix

columnrow

Hi, We have a matrix (480 x 23) and we need to extract data from it. For example: in column 5 there are the numbers of 1 to 6 and we need to extract the numbers 1. At the same we need the corresponding reaction times of these values which can be found in column 14. Thus far, we have
[n,m]=size(trialList);
for k=1:n;
r = trialList(k,5);
if r == 1
disp ('trailList14');
end
end
We are able to find the 80 rows where number 1 is mentioned. But instead showing the 80 corresponding reaction times, Matlab shows 80 times the word 'triallist14'.
How will we be able to select the corresponding reaction times with the corresponding values of column 5?

Best Answer

vals=trialList(find(trialList(:,5)==1),[5 14]);
Related Question