% CHOICE REACTION TIME red=ones(500,500); red(:,:,2)=zeros(500,500); red(:,:,3)=zeros(500,500); green=zeros(500,500); green(:,:,2)=ones(500,500); green(:,:,3)=zeros(500,500); blue=zeros(500,500); blue(:,:,2)=zeros(500,500); blue(:,:,3)=ones(500,500); black=zeros(500,500,3); white=ones(500,500,3); yellow=ones(500,500); yellow(:,:,2)=ones(500,500); yellow(:,:,3)=zeros(500,500); msgbox('CHOICE REACTION TIME. In this module press left or right arrow, depending if left or right image is displayed. Now click OK and press any key.') sprintf('Get ready for the test and press any key...') pause close all figure(1) subplot(1,2,1) imagesc(white) axis off hold on subplot(1,2,2) imagesc(white) axis off hold on pause(2) num=0; r=0; g=0; while num<25 value=0; num=num+1; n=ceil(2*rand(1,1)) switch n case 1 r=r+1; subplot(1,2,1) imagesc(red) tic while value~=28 k=waitforbuttonpress; value = double(get(gcf,'CurrentCharacter')) end times(num)=toc; typ(num)=0; rtimes(r)=times(num); imagesc(white) pause(0.5) case 2 g=g+1; subplot(1,2,2) imagesc(green) tic while value~=29 k=waitforbuttonpress; value = double(get(gcf,'CurrentCharacter')) end times(num)=toc; typ(num)=1; gtimes(g)=times(num); imagesc(white) pause(0.5) end end x=[]; y=[]; for i=1:length(typ) y=[y,typ(i),typ(i),typ(i)]; x=[x,i-0.5,i,i+0.5]; end close times reaction_mean = mean(times) plot(times) hold on plot(x,y,'o--') xlabel('sample/probka') % x-axis label ylabel('time/czas [s]') % y-axis label