clear all

ListFile = dec2bin(hex2dec(cell2mat(textread('TEST_removehead.lst','%s')))); % Import listfile data
Sweeps = bin2dec(ListFile(:,1:16)); % extract variable Sweeps for each count
ToF = round(bin2dec(ListFile(:,17:44))/4); % extract variable ToF for each count
Counts = length(Sweeps);
MassIndex = zeros(Counts,1);
j = 0;
for i = 1:Counts-1
   MassIndex(i) = floor((Sweeps(i)+j*2^16)/3600);
   if Sweeps(i+1) < Sweeps(i)
       j = j+1;
   end
end
ZeroCorrection = MassIndex == 0;
MassIndex = MassIndex+ZeroCorrection;
Range = 30016;
Cycles = 325;
MP_Data = zeros(Range*Cycles,1);

for i = 1:Counts
    j = MassIndex(i)*Range-Range+ToF(i);
    MP_Data(j) = MP_Data(j)+1;
end



