clear all

A = [importdata('test.xlsx') importdata('test2.xlsx')] ; 
% add files if needed but excel files need to be same length!!!!

p = [2:8];

for i = 1:length(A)/10; % change i. i is same as amount of files you wanna read

neutral(:,i) = str2num(cell2mat(A(2:end,p(1))));
maxneutral(i) = max(neutral(:,i));
meanneutral(i) = mean(neutral(:,i));

happy(:,i) = str2num(cell2mat(A(2:end,p(2))));
maxhappy(i) = max(happy(:,i));
meanhappy(i) = mean(happy(:,i));

sad(:,i) = str2num(cell2mat(A(2:end,p(3))));
maxsad(i) = max(sad(:,i));
meansad(i) = mean(sad(:,i));

angry(:,i) = str2num(cell2mat(A(2:end,p(4))));
maxangry(i) = max(angry(:,i));
meanangry(i) = mean(angry(:,i));

surprised(:,i) = str2num(cell2mat(A(2:end,p(5))));
maxsurprised(i) = max(surprised(:,i));
meansurprised(i) = mean(surprised(:,i));

scared(:,i) = str2num(cell2mat(A(2:end,p(6))));
maxscared(i) = max(scared(:,i));
meanscared(i) = mean(scared(:,i));

disgusted(:,i) = str2num(cell2mat(A(2:end,p(7))));
maxdisgusted(i) = max(disgusted(:,i));
meandisgusted(i) = mean(disgusted(:,i));

p = p+10;
end

meanmeanneutral = mean(meanneutral);
meanmeanhappy = mean(meanhappy);
meanmeansad = mean(meansad);
meanmeanangry = mean(meanangry);
meanmeansurprised = mean(meansurprised);
meanmeanscared = mean(meanscared);
meanmeandisgusted = mean(meandisgusted);

errorneutral = std(meanneutral);
errorhappy = std(meanhappy);
errorsad = std(meansad);
errorangry = std(meanangry);
errorsurprised = std(meansurprised);
errorscared = std(meanscared);
errordisgusted = std(meandisgusted);


y1 = [meanmeanneutral meanmeanhappy meanmeansad meanmeanangry meanmeansurprised meanmeanscared meanmeandisgusted];
erry1 = [errorneutral errorhappy errorsad errorangry errorsurprised errorscared errordisgusted];
str = {'Neutral'; 'Happy'; 'Sad';'Angry'; 'Surprised'; 'Scared'; 'Disgusted'};
figure 
barwitherr(erry1,y1)
title('Expected emotion: Happy') %change name is needed
set(gca, 'XTickLabel',str, 'XTick',1:numel(str))
ylabel('Intensity')

y2 = [meanmeanhappy meanmeansad meanmeanangry meanmeansurprised meanmeanscared meanmeandisgusted];
erry2 = [errorhappy errorsad errorangry errorsurprised errorscared errordisgusted];
str = {'Happy'; 'Sad';'Angry'; 'Surprised'; 'Scared'; 'Disgusted'};
figure 
barwitherr(erry2,y2)
title('Expected emotion: Happy')
set(gca, 'XTickLabel',str, 'XTick',1:numel(str))
ylabel('Intensity')