prompt = {'Enter context ID:'};
dlgtitle = 'Input';
dims = [1 35];
definput = {''};
answer = inputdlg(prompt,dlgtitle,dims,definput);

contextId = answer{1};

dir = strcat("D:\tracings\", contextId);

files = ls(strcat(dir,"\*_*"));

for k = 1 : length(files(:,1))
  A(k) = strtrim(string(files(k,:)));
  fprintf('Sub folder #%d = %s\n', k, files(k,:));
  
  upVotes(k,:) = csvread(strcat(dir, "\", A(k), "\upVoteTrace.csv"));
  downVotes(k,:) = csvread(strcat(dir, "\", A(k), "\downVoteTrace.csv"));
  abuseVotes(k,:) = csvread(strcat(dir, "\", A(k), "\abuseVoteTrace.csv"));
  replies(k,:) = csvread(strcat(dir, "\", A(k), "\replyTrace.csv"));

  combinated(k,:) = upVotes(k,:) + replies(k,:) - downVotes(k,:) - abuseVotes(k,:);
  
end

x = (0:1:143);

plot(x, combinated(1,:));
hold on;
plot(x, combinated(2,:));
plot(x, combinated(3,:));
plot(x, combinated(4,:));
plot(x, combinated(5,:));
plot(x, combinated(6,:));
plot(x, combinated(7,:));
plot(x, combinated(8,:));
plot(x, combinated(9,:));
plot(x, combinated(10,:));
hold off;
legend('position 1','position 2','position 3','position 4','position 5','position 6','position 7','position 8','position 9','position 10');


for i = 1 : 9
subplot(3,3,i);
x = (1:1:144);
cumcombLast = cumsum(combinated(i,120:144));
cumcomb = cumsum(combinated(i,:));
plot(x, combinated(i,1:144));
%plot(x,cumcombLast,x,cumcomb(120:144));
y = (0:1:143);
%plot(y,combinated(i,:));
ylim([0 10]);
xlim([0 144]);
title(strcat('Position',{' '},files(i,1:3),':'));
end



