global cstrings cstringsmax numresponses  filename matrix


%4 x SOA x IDD
      %Soa 1 = 107,  2 = 53ms
      %IDD 1 = no IDDS, 2 = 1 IDD
      


      start=1;
      finish = 4;
      if(cstringsmax(1,1,1) ==0)
          start = 1;
      end
     
for(lag = 1:2)
    for(numtargs = 1:1)
        matrix(:,:,lag,numtargs) = matrix(:,:,lag,numtargs)/cstringsmax(1,lag,numtargs);   %first find the mean
        omean = mean( cstrings(start:finish,lag,numtargs)./ cstringsmax(start:finish,lag,numtargs));
        %uncomment this to demean the whole matrix by its own mean
        %        matrix(:,:,lag,numtargs) = matrix(:,:,lag,numtargs)/omean; %  demean it with the overall mean

        tmeans = cstrings(start:finish,lag,numtargs)./ cstringsmax(start:finish,lag,numtargs);


        %uncomment this to normalize matrix by target accuracies
        for( c = 1:4)
            %        matrix(c,:,lag,numtargs) = matrix(c,:,lag,numtargs)/tmeans(c); %  demean it with the overall mean
        end
    end
end 
      
 fr = fopen(sprintf('showresults%s.txt',filename),'w');
 
fprintf(fr,'Accuracy for TTTT\n');

fprintf(fr,'%0.2g  ', cstrings(start:finish,1,1)./ cstringsmax(start:finish,1,1));
 fprintf(fr,'\n');
 fprintf(fr,'overallmean %0.2g   numresponses %d   numtrials %d\n\n\n', mean( cstrings(start:finish,1,1)./ cstringsmax(start:finish,1,1)),numresponses(1,1),cstringsmax(start,1,1));
 fprintf(fr,'%5.2g ' ,matrix(1,:,1,1));
fprintf(fr,'\n');
fprintf(fr,'%5.2g ' ,matrix(2,:,1,1));
fprintf(fr,'\n');
fprintf(fr,'%5.2g ' ,matrix(3,:,1,1));
fprintf(fr,'\n');
fprintf(fr,'%5.2g ' ,matrix(4,:,1,1));
fprintf(fr,'\n'); fprintf(fr,'\n');
 
  fprintf(fr,'Accuracy for  TDTDTDT\n');

fprintf(fr,'%0.2g  ', cstrings(start:finish,2,1)./ cstringsmax(start:finish,2,1));
 fprintf(fr,'\n');
 fprintf(fr,'overallmean %0.2g   numresponses %d  numtrials %d\n\n\n', mean( cstrings(start:finish,2,1)./ cstringsmax(start:finish,2,1)),numresponses(2,1),cstringsmax(start,2,1));

 fprintf(fr,'%5.2g ' ,matrix(1,:,2,1));
fprintf(fr,'\n');
fprintf(fr,'%5.2g ' ,matrix(2,:,2,1));
fprintf(fr,'\n');
fprintf(fr,'%5.2g ' ,matrix(3,:,2,1));
fprintf(fr,'\n');
fprintf(fr,'%5.2g ' ,matrix(4,:,2,1));
fprintf(fr,'\n'); fprintf(fr,'\n');

 
 
 fclose(fr)     ;