% unr: script to score vowel identification experiment clear all; close all; % load pa.mat load(uigetfile('*.mat','Enter .mat file with listener data')); hvd=char('heed','hid','hayed','head','had','hud','hod','herd','hoed','hood','whod'); VOW=char('ii','il','ee','el','al','uh','aa','er','oo','ul','uu'); talkers=char('k7br','kacr','kakg'); [ntalkers,nchar]=size(talkers); %#ok cm=zeros(11,11); [nfiles,nchar]=size(stimlist); cor=zeros(11,3); for i=1:nfiles stim=stimlist(i,:); itkr=strmatch(stim(1:4),talkers); ivow=strmatch(stim(5:6),VOW); resp=deblank(char(resplist(i,:))); iresp=strmatch(resp,VOW); if strcmp(stim(5:6),resp), cor(ivow,itkr)=cor(ivow,itkr)+1; end; cm(ivow,iresp)=cm(ivow,iresp)+1; end; clc; disp(['Identification accuracy = ' int2str(sum(sum(cor))/nfiles*100) '%']); disp('Confusion matrix') disp([' heed',' hid',' hayed',' head',' had',' hud',' hod',' herd',' hoed',' hood',' whod']) for istim=1:11 fprintf('%s',hvd(istim,:)) for iresp=1:11 fprintf('%5.0f ',cm(istim,iresp)/ntalkers*100); end fprintf('\n'); end imagesc(cm*100) colormap(cool) axis ij set(gca,'XTickLabel',hvd,'YTickLabel',hvd) for istim=1:11 for iresp=1:11 percent_score=cm(istim,iresp)/ntalkers*100; text(istim,iresp,int2str(percent_score),'FontSize',8); end fprintf('\n'); end set(gca,'TickDir','Out'); title('Confusion matrix');