clear;

EnergiesTotal=zeros(1);
for foldercount=1:1:32
    filename = "X:\CPU_Collected\ncku_dd\20250610(" + foldercount + ").xlsx";
    data=readmatrix(filename);
    data=data(2:end,:);
    datalength=length(data);    
    Energies=data(:,1);   
    EnergiesTotal=[EnergiesTotal;Energies];
end
EnergiesTotal=EnergiesTotal(2:end);
edges = 0:0.01:6;
histogram(EnergiesTotal,edges);
xlabel('Energy (TBD)');
ylabel('Counts');
saveas(gcf, "X:\CPU_Collected\ncku_dd\dd_Histogram.png");
[counts, edges] = histcounts(EnergiesTotal, 'BinEdges', edges);
bincenter=( edges+circshift(edges,-1) )./2;
bincenter=bincenter(1:end-1);
histogramoutput=transpose([bincenter;counts]);
title=["bincenter", "counts"];
filenameoutput="X:\CPU_Collected\ncku_dd\dd_Histogram.xlsx";
writematrix([title; histogramoutput ], filenameoutput);

