A=[30 30 30 30 30 30 60 60 60 60 60 60 60 60 30 30 30 30 30 30];
A1 = A;
A = A1 > 30;
n2 = numel(A);
b2 = nnz(A);
M2 = 0:ones(1,n2)*pow2(n2-1:-1:0)';
z2 = rem(floor(M2(:)*pow2(1-n2:0)),2);
ii = z2(sum(z2,2) == b2,:);
aa = [30 60];
out = aa(ii + 1);
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!