responsetimes = [ 2.4 2.2 2.9 2.7 2.7; 1.6 1.7 1.9 1.5 1.0; 2.1 2.2 0.9 2.5 1.9; 1.7 2.4 1.6 2.1 1.4 ] calculate the mean response times for each trial in matlab

To calculate the mean response times for each trial in Matlab, we can use the mean() function along the rows of the matrix.

Here's how to do it:

main.m
% define the response times matrix
responsetimes = [ 2.4 2.2 2.9 2.7 2.7;  1.6 1.7 1.9 1.5 1.0; 2.1 2.2 0.9 2.5 1.9; 1.7 2.4 1.6 2.1 1.4 ];

% calculate the mean response times along the rows
meanresponsetimes = mean(responsetimes, 2);

% display the mean response times
disp(meanresponsetimes);
296 chars
9 lines

This will output a column vector containing the mean response time for each trial, as follows:

main.m
2.58
1.54
1.92
1.84
20 chars
5 lines

Note that we've used the 2 parameter to specify that we want to take the mean along the rows of the matrix. Alternatively, we could use 1 to take the mean along the columns.

gistlibby LogSnag