MATLAB: Random number generation with changing probability

random number generator

hi all,
I want to generate either 0 or 1 randomly 50 times but with changing probability for 1 and 0. For example if i do 50 trails then for the first 10 trails 1 should definitely come means probability of occurrence of 1 is 1 and 0 is 0, for next 10 trails probability of occurrence of 1 becomes 0.75 and 0 becomes 0.25 means for this 10 trails 1 should come more often that 0, for next 30 trails probability of occurrence of 1 becomes 0.5 and 0 becomes 0.5. Can anyone suggest me how to do this ??

Best Answer

a=randsrc(10,1,[1 0;1 0]);
b=randsrc(10,1,[1 0;.75 .25]);
c=randsrc(30,1,[1 0; .5 .5]);
data=[a; b; c]
Related Question