How to display a subjects mean reaction time as a bar chart?

4 views (last 30 days)
Hi, I have collected participants reaction time to the presentation of stimuli. I have the reaction time data for 4 participants, these are saved in a CSV file along with their keyboard response. I was wondering how you could go about extracting the mean reaction time for each participant, and displaying this in an individual bar chart for each participant.
Also is there a way of combining the reaction times for each participant, and displaying that in a single bar chart?
T=table(response,rts);
writetable(T,'participant_01_sequence.csv'); %this is how I saved participants response and their reaction time in a CSV file
Thank you for any help anyone can offer.

Answers (1)

Soumya
Soumya on 19 Jun 2025
Edited: Soumya on 19 Jun 2025
You can calculate the mean reaction time for each individual participant using MATLAB's ‘mean’ function. Once the mean values are obtained, you can visualize the data using bar charts with the ‘bar’ function. These charts can be generated individually for each participant to highlight personal performance or combined in a single plot for easy comparison across all participants.
The following steps will help you achieve it:
  • Put the csv files in a cell array and calculate the length of the array. Also, pre allocate the variable you are using to store the mean values:
NumParticipants = length(filenames);
meanRTs = zeros(numParticipants,1);
  • Use a for loop, and extract the rts values from each of the csv files and then apply ‘mean’ to it:
for i = 1:numParticipants
T = readtable(filenames{i});
meanRTs(i) = mean(T.rts);
end
  • After this, you can plot it individually using the ‘bar’ function:
for i = 1:numParticipants
figure;
bar(meanRTs(i));
end
  • If you want to put the bar graph together in one plot, you can try this:
figure;
bar(meanRTs);
title('Mean Reaction Time for All Participants');
The following are the received outputs:
The following documentation links will help you get more information on the following functions:
I hope this helps!

Categories

Find more on View and Analyze Simulation Results 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!