excludelist = [];
excludelist(1).resAtomRho = [];

% % % excludelist(1).resAtomRho  = [12 18];
% % % excludelist(2).resAtomRho  = [26 52];
% % % excludelist(3).resAtomRho  = [38 6];
% % % excludelist(4).resAtomRho  = [30 5];



clearvars diagDecayCalc diagDecayGroups

diagDecayCalc = diagDecay;

count.all               = 1;
count.HN                = 1;
count.HA                = 1;
count.methylene         = 1;
count.methylenePseudo   = 1;
count.methyl            = 1;
count.methylPseudo      = 1;
    
for i = 1:length(diagDecayCalc)
    
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    
    exclude = 0;
    
    resAtomRho = [diagDecay(i).numcode.ASSi, diagDecay(i).numcode.ATOMi];
    
    for k = 1:length(excludelist)
    
        if ((ismember(resAtomRho, excludelist(k).resAtomRho)));
            exclude = 1;
        end
    end

    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    if exclude == 0
        
        diagDecayGroups.all.group(count.all)                            = diagDecayCalc(i);
        count.all                                                       = count.all + 1;
        
    end
    
    if diagDecayCalc(i).numcode.ATOMi == 1 && exclude == 0
        
        diagDecayGroups.HN.group(count.HN)                              = diagDecayCalc(i);
        count.HN                                                        = count.HN + 1;
        
    end
    
    if ismember(diagDecayCalc(i).numcode.ATOMi, [2 9 20]) && exclude == 0
        
        diagDecayGroups.HA.group(count.HA)                              = diagDecayCalc(i);
        count.HA                                                        = count.HA + 1;
        
    end
    
    if ismember(diagDecayCalc(i).numcode.ATOMi, [conditions.methylene(1:13).atoms]) && exclude == 0
        
        
        diagDecayGroups.methylene.group(count.methylene)                = diagDecayCalc(i);
        count.methylene                                                 = count.methylene + 1;
       
    end
    
    if ismember(diagDecayCalc(i).numcode.ATOMi, [conditions.methylene(1:15).grpNum]) && exclude == 0
        
        
        diagDecayGroups.methylenePseudo.group(count.methylenePseudo)    = diagDecayCalc(i);
        count.methylenePseudo                                           = count.methylenePseudo + 1;
       
    end
    
    if ismember(diagDecayCalc(i).numcode.ATOMi, [conditions.methyl(1:8).atoms]) && exclude == 0
        
        diagDecayGroups.methyl.group(count.methyl)                      = diagDecayCalc(i);
        count.methyl                                                    = count.methyl + 1;
        
    end
    
    if ismember(diagDecayCalc(i).numcode.ATOMi, [conditions.methyl(1:10).grpNum]) && exclude == 0
        
        diagDecayGroups.methylPseudo.group(count.methylPseudo)          = diagDecayCalc(i);
        count.methylPseudo                                              = count.methylPseudo + 1;
        
    end
    
end

fprintf('all')
diagDecayGroups.all.numMembers                  = length(diagDecayGroups.all.group);
diagDecayGroups.all.rhoAvg                      = sum([diagDecayCalc.rho])                              /diagDecayGroups.all.numMembers;
diagDecayGroups.all.ConstAvg                    = sum([diagDecayCalc.Const])                            /diagDecayGroups.all.numMembers;
diagDecayGroups.all.chiNRhoAvg                  = sum([diagDecayCalc.chiNRho])                          /diagDecayGroups.all.numMembers;
diagDecayGroups.all
fprintf('\n\n')

if isfield(diagDecayGroups, 'HN')
    fprintf('HN')
    fprintf('\nATOM NUMBERCODES belonging to this group are: \n')
    fprintf('1')
    fprintf('\n')
    diagDecayGroups.HN.numMembers               = length(diagDecayGroups.HN.group);
    diagDecayGroups.HN.rhoAvg                   = sum([diagDecayGroups.HN.group.rho])                   /diagDecayGroups.HN.numMembers;
    diagDecayGroups.HN.ConstAvg                 = sum([diagDecayGroups.HN.group.Const])                 /diagDecayGroups.HN.numMembers;
    diagDecayGroups.HN.chiNRhoAvg               = sum([diagDecayGroups.HN.group.chiNRho])               /diagDecayGroups.HN.numMembers;
    diagDecayGroups.HN
    fprintf('\n\n')
end

if isfield(diagDecayGroups,'HA')
    fprintf('HA')
    fprintf('\nATOM NUMBERCODES belonging to this group are: \n')
    fprintf('2 9 20')
    fprintf('\n')
    diagDecayGroups.HA.numMembers               = length(diagDecayGroups.HA.group);
    diagDecayGroups.HA.rhoAvg                   = sum([diagDecayGroups.HA.group.rho])                   /diagDecayGroups.HA.numMembers;
    diagDecayGroups.HA.ConstAvg                 = sum([diagDecayGroups.HA.group.Const])                 /diagDecayGroups.HA.numMembers;
    diagDecayGroups.HA.chiNRhoAvg               = sum([diagDecayGroups.HA.group.chiNRho])               /diagDecayGroups.HA.numMembers;
    diagDecayGroups.HA
    fprintf('\n\n')
end

if isfield(diagDecayGroups, 'methylene')
    fprintf('methylene')
    fprintf('\nATOM NUMBERCODES belonging to this group are: \n')
    num2str([conditions.methylene(1:13).atoms])
    fprintf('\n')
    diagDecayGroups.methylene.numMembers        = length(diagDecayGroups.methylene.group);
    diagDecayGroups.methylene.rhoAvg            = sum([diagDecayGroups.methylene.group.rho])            /diagDecayGroups.methylene.numMembers;
    diagDecayGroups.methylene.ConstAvg          = sum([diagDecayGroups.methylene.group.Const])          /diagDecayGroups.methylene.numMembers;
    diagDecayGroups.methylene.chiNRhoAvg        = sum([diagDecayGroups.methylene.group.chiNRho])        /diagDecayGroups.methylene.numMembers;
    diagDecayGroups.methylene
    fprintf('\n\n')
end

if isfield(diagDecayGroups, 'methylenePseudo')
    fprintf('methylenePseudo')
    fprintf('\nATOM NUMBERCODES belonging to this group are: \n')
    num2str([conditions.methylene(1:15).grpNum])
    fprintf('\n')
    diagDecayGroups.methylenePseudo.numMembers        = length(diagDecayGroups.methylenePseudo.group);
    diagDecayGroups.methylenePseudo.rhoAvg            = sum([diagDecayGroups.methylenePseudo.group.rho])            /diagDecayGroups.methylenePseudo.numMembers;
    diagDecayGroups.methylenePseudo.ConstAvg          = sum([diagDecayGroups.methylenePseudo.group.Const])          /diagDecayGroups.methylenePseudo.numMembers;
    diagDecayGroups.methylenePseudo.chiNRhoAvg        = sum([diagDecayGroups.methylenePseudo.group.chiNRho])        /diagDecayGroups.methylenePseudo.numMembers;
    diagDecayGroups.methylenePseudo
    fprintf('\n\n')
end

if isfield(diagDecayGroups, 'methyl')
    fprintf('methyl')
    fprintf('\nATOM NUMBERCODES belonging to this group are: \n')
    num2str([conditions.methyl(1:8).atoms])
    fprintf('\n')
    diagDecayGroups.methyl.numMembers           = length(diagDecayGroups.methyl.group);
    diagDecayGroups.methyl.rhoAvg               = sum([diagDecayGroups.methyl.group.rho])               /diagDecayGroups.methyl.numMembers;
    diagDecayGroups.methyl.ConstAvg             = sum([diagDecayGroups.methyl.group.Const])             /diagDecayGroups.methyl.numMembers;
    diagDecayGroups.methyl.chiNRhoAvg           = sum([diagDecayGroups.methyl.group.chiNRho])           /diagDecayGroups.methyl.numMembers;
    diagDecayGroups.methyl
    fprintf('\n\n')
end

if isfield(diagDecayGroups, 'methylPseudo')
    fprintf('methylPseudo')
    fprintf('\nATOM NUMBERCODES belonging to this group are: \n')
    num2str([conditions.methyl(1:10).grpNum])
    fprintf('\n')
    diagDecayGroups.methylPseudo.numMembers        = length(diagDecayGroups.methylPseudo.group);
    diagDecayGroups.methylPseudo.rhoAvg            = sum([diagDecayGroups.methylPseudo.group.rho])            /diagDecayGroups.methylPseudo.numMembers;
    diagDecayGroups.methylPseudo.ConstAvg          = sum([diagDecayGroups.methylPseudo.group.Const])          /diagDecayGroups.methylPseudo.numMembers;
    diagDecayGroups.methylPseudo.chiNRhoAvg        = sum([diagDecayGroups.methylPseudo.group.chiNRho])        /diagDecayGroups.methylPseudo.numMembers;
    diagDecayGroups.methylPseudo
    fprintf('\n\n')
end


