% This program gives a compilation fo the entire data for NSCM. Only errors above that of the average control group are shown. More details about 
% the number of presentations is also given

load('DataNSCM/mastconf.mat')
load('DataNSCM/mastconb.mat')
load('DataNSCM/mastvowf.mat')
load('DataNSCM/astvowb.mat')

child={'Alina','Angela','Anton','Bob','Carly','Edward','Evan','Joanna','Latisha','Laura','Miguel','Norene','Shauna','Teddy','Tony'};
vow={'' '@' 'A' 'E' 'I' 'O' 'R' 'U' 'W' 'Y' 'a' 'c' 'e' 'i' 'o' 'u'};
cons={'' 'C' 'D' 'G' 'H' 'J' 'S' 'T' 'Z' 'b' 'd' 'f' 'g' 'h' 'k' 'l' 'm' 'n' 'p' 'r' 's' 't' 'v' 'w' 'y' 'z'};

vow1={'@' 'A' 'E' 'I' 'O' 'R' 'U' 'W' 'Y' 'a' 'c' 'e' 'i' 'o' 'u'};
cons1={'C' 'D' 'G' 'H' 'J' 'S' 'T' 'Z' 'b' 'd' 'f' 'g' 'h' 'k' 'l' 'm' 'n' 'p' 'r' 's' 't' 'v' 'w' 'y' 'z'};

% 
[Y1,I1]=sort(sum([mastconf(3:5,1:25);mastconf(7:8,1:25);mastconf(11,1:25)],1)./sum([mastconf(3:5,26:50);mastconf(7:8,26:50);mastconf(11,26:50)],1),2,'descend');
[Y2,I2]=sort(sum([mastconb(3:5,1:25);mastconb(7:8,1:25);mastconb(11,1:25)],1)./sum([mastconb(3:5,26:50);mastconb(7:8,26:50);mastconb(11,26:50)],1),2,'descend');
[Y3,I3]=sort(sum([mastvowf(3:5,1:15);mastvowf(7:8,1:15);mastvowf(11,1:15)],1)./sum([mastvowf(3:5,16:30);mastvowf(7:8,16:30);mastvowf(11,16:30)],1),2,'descend');
[Y4,I4]=sort(sum([mastvowb(3:5,1:15);mastvowb(7:8,1:15);mastvowb(11,1:15)],1)./sum([mastvowb(3:5,16:30);mastvowb(7:8,16:30);mastvowb(11,16:30)],1),2,'descend');

[YO1,IO1]=sort(sum(mastconf(:,1:25),2)./sum(mastconf(:,26:50),2),1,'descend');
[YO2,IO2]=sort(sum(mastconb(:,1:25),2)./sum(mastconb(:,26:50),2),1,'descend');
[YO3,IO3]=sort(sum(mastvowf(:,1:15),2)./sum(mastvowf(:,16:30),2),1,'descend');
[YO4,IO4]=sort(sum(mastvowb(:,1:15),2)./sum(mastvowb(:,16:30),2),1,'descend');




exel11(1,2:26)=cons1(1,I1);
exel12(1,2:26)=cons1(1,I1);
exel21(1,2:26)=cons1(1,I2);
exel22(1,2:26)=cons1(1,I2);
exel31(1,2:16)=vow1(1,I3);
exel32(1,2:16)=vow1(1,I3);
exel41(1,2:16)=vow1(1,I4);
exel42(1,2:16)=vow1(1,I4);

for i=1:15
    exel11(i+1,1)={child{1,IO1(i,1)}};
    exel12(i+1,1)={child{1,IO1(i,1)}};
    exel21(i+1,1)={child{1,IO2(i,1)}};
    exel22(i+1,1)={child{1,IO2(i,1)}};
    exel31(i+1,1)={child{1,IO3(i,1)}};
    exel32(i+1,1)={child{1,IO3(i,1)}};
    exel41(i+1,1)={child{1,IO4(i,1)}};
    exel42(i+1,1)={child{1,IO4(i,1)}};
    
    for j1=1:25
        if ~isnan(mastconf(IO1(i,1),I1(1,j1))/mastconf(IO1(i,1),I1(1,j1)+25))
            if (mastconf(IO1(i,1),I1(1,j1))/mastconf(IO1(i,1),I1(1,j1)+25))<Y1(1,j1) 
            exel11(i+1,j1+1)={num2str((1-(mastconf(IO1(i,1),I1(1,j1))./mastconf(IO1(i,1),I1(1,j1)+25)))*100)};
            exel12(i+1,j1+1)={[num2str(mastconf(IO1(i,1),I1(1,j1)+25)-mastconf(IO1(i,1),I1(1,j1))) ' of ' num2str(mastconf(IO1(i,1),I1(1,j1)+25))]};
            else
                exel11(i+1,j1+1)={''};
                exel12(i+1,j1+1)={''};
            end 
        else
            exel11(i+1,j1+1)={'---'};
            exel12(i+1,j1+1)={'---'};
            
        end
        
        
        if ~isnan(mastconb(IO2(i,1),I2(1,j1))/mastconb(IO2(i,1),I2(1,j1)+25))
            if (mastconb(IO2(i,1),I2(1,j1))/mastconb(IO2(i,1),I2(1,j1)+25))<Y2(1,j1)
            exel21(i+1,j1+1)={num2str((1-(mastconb(IO2(i,1),I2(1,j1))/mastconb(IO2(i,1),I2(1,j1)+25)))*100)};
            exel22(i+1,j1+1)={[num2str(mastconb(IO2(i,1),I2(1,j1)+25)-mastconb(IO2(i,1),I2(1,j1))) ' of ' num2str(mastconb(IO2(i,1),I2(1,j1)+25))]};
            else
                exel21(i+1,j1+1)={''};
                exel22(i+1,j1+1)={''};
            end 
        else
            exel21(i+1,j1+1)={'---'};
            exel22(i+1,j1+1)={'---'};
        end
        
        
        
        
        
        
    end
    
    
    for j2=1:15
        if ~isnan(mastvowf(IO3(i,1),I3(1,j2))/mastvowf(IO3(i,1),I3(1,j2)+15))
            if (mastvowf(IO3(i,1),I3(1,j2))/mastvowf(IO3(i,1),I3(1,j2)+15))<Y3(1,j2)
            exel31(i+1,j2+1)={num2str((1-(mastvowf(IO3(i,1),I3(1,j2))/mastvowf(IO3(i,1),I3(1,j2)+15)))*100)};
            exel32(i+1,j2+1)={[num2str(mastvowf(IO3(i,1),I3(1,j2)+15)-mastvowf(IO3(i,1),I3(1,j2))) ' of ' num2str(mastvowf(IO3(i,1),I3(1,j2)+15))]};
            else
                exel31(i+1,j2+1)={''};
                exel32(i+1,j2+1)={''};
            end 
        else
            exel31(i+1,j2+1)={'---'};
            exel32(i+1,j2+1)={'---'};
        end
        
        
        
        if ~isnan(mastvowb(IO4(i,1),I4(1,j2))/mastvowb(IO4(i,1),I4(1,j2)+15))
            if (mastvowb(IO4(i,1),I4(1,j2))/mastvowb(IO4(i,1),I4(1,j2)+15))<Y4(1,j2)
            exel41(i+1,j2+1)={num2str((1-(mastvowb(IO4(i,1),I4(1,j2))/mastvowb(IO4(i,1),I4(1,j2)+15)))*100)};
            exel42(i+1,j2+1)={[num2str(mastvowb(IO4(i,1),I4(1,j2)+15)-mastvowb(IO4(i,1),I4(1,j2))) ' of ' num2str(mastvowb(IO4(i,1),I4(1,j2)+15))]};
            else
                exel41(i+1,j2+1)={''};
                exel42(i+1,j2+1)={''};
            end 
        else
            exel41(i+1,j2+1)={'---'};
            exel42(i+1,j2+1)={'---'};
        end
        
        
    end
    
end    



%xlswrite('C:\Users\Anjali\Documents\MATLAB\NewFolder1\Reading Group\NSCM\NSCM.xlsx',exel11,1,'A1:Z16');
%xlswrite('C:\Users\Anjali\Documents\MATLAB\NewFolder1\Reading Group\NSCM\NSCM.xlsx',exel12,2,'A1:Z16');
%xlswrite('C:\Users\Anjali\Documents\MATLAB\NewFolder1\Reading Group\NSCM\NSCM.xlsx',exel21,3,'A1:Z16');
%xlswrite('C:\Users\Anjali\Documents\MATLAB\NewFolder1\Reading Group\NSCM\NSCM.xlsx',exel22,4,'A1:Z16');
%xlswrite('C:\Users\Anjali\Documents\MATLAB\NewFolder1\Reading Group\NSCM\NSCM.xlsx',exel31,5,'A1:P16');
%xlswrite('C:\Users\Anjali\Documents\MATLAB\NewFolder1\Reading Group\NSCM\NSCM.xlsx',exel32,6,'A1:P16');
%xlswrite('C:\Users\Anjali\Documents\MATLAB\NewFolder1\Reading Group\NSCM\NSCM.xlsx',exel41,7,'A1:P16');
%xlswrite('C:\Users\Anjali\Documents\MATLAB\NewFolder1\Reading Group\NSCM\NSCM.xlsx',exel42,8,'A1:P16');
