I have the following program:
我有以下程序:
m = 4;
N = 3;
a = [ones(N+m-1,1)' zeros(m,1)']; % creates an array with specified number of 0's and 1's
b = perms(a);
c = unique(b,'rows'); % with these last two lines, I find all possible combinations
% the rest is probably not relevant for the question
d = [ones(length(c),1) c ones(length(c),1)];
a_powers = zeros(length(d(:,1)),1);
for i = 1:length(d(:,1))
a_powers(i) = nnz(diff(d(i,:))==0);
end
[n_terms,which_power]=hist(a_powers',unique(a_powers'));
m = 4