I am not exactly certain about the final result you want, but here is a smaller example (so the output is easier to inspect), with the maximum power of 2 you want, and the number of layers (as parameters you can adjust).
Take a look at see if it gives the result you expect. If not, perhaps you can see how to edit it, or tell us what result you would actually want in this case.
MAX_POW = 2; % 2^MAX_POW neurons per layer
NUM_LAYERS = 3; % Number of layers
% Generate all the combinations
n = 2.^(fullfact(repmat(MAX_POW+1,1,NUM_LAYERS)) - 1);
% Replace the 1's with 0's
n(n==1) = 0
