I am trying to make an index all possible molecules with 0-46 Hydrogen, 0-20 carbon, 0-13 oxygen, etc. I have 7 atoms in which I am interested: H, C, O, N, Cl, F, and S. I have written the following for loop to show what I am trying to achieve:
MassListIndex = []
%MassIndex = [h,c,o,n,cl,f,s]
for h = 0:46;
for c = 0:20;
for o = 0:13;
for n = 0:15;
for cl=0:5;
for f=0:5;
for s=0:5;
MassListIndex = [MassListIndex;[h,c,o,n,cl,f,s]];
end;
end;
end;
end;
end;
end;
end;
This strikes me as terribly inefficient; I don't want to wait around for 2 months for this to run. I have tried using the combinator.m script, but the problem is that there is only one input for the length of the set that is 'permutated' ie if I want to have up to 46 hydrogens, I need to also have 46 of each of the other 6 atoms. This is computationally...heavy (46^7 ~= 436 billion).
Is there any way to make this sort of computation more efficient? Or do I need to think more about shrinking my list by riding it of 'nonsense permutations' (As far as I know, the molecule H40C2 has never been observed!)
Thanks