Hi All,
I have an array of zeros from 1:400 and want to randomly assign ones in 10 positions for every 40 zeros in the sequence.
cycles = 40;count = 0;state = zeros(1, 400);for i = 1:cycles tempstate = state(count:count+cycles) for j = 1:10 tempstate(randi(numel(tempstate))) =1 end count = count + 40
The issue I have is that I want wherever I assign a one to have a zero either side.
But still maintain 10 1's per 40 positions in the sequence.
Appreciate the help.
Thanks,
David
Best Answer