c=[]; for i=1:length(b) c = [c a(i)*ones(1,b(i))]; z=[a;b]; for v=z c = [c v(1)*ones(1,v(2))]; end while any(~(diff(c))) c=c(randperm(sum(b))); end