MATLAB: Binary generator

matlab function

i want to have a binary generator with the equal probalbility for 0 and1 and i dont know how to wite and even help didn't help me

Best Answer

See the rand function. There are various ways to get 0 1 results depending on what you are doing with it downstream. Do you want a double result or a logical result? e.g., logical result could use
rand(n,1)<.5
Or a double result could use
floor(rand(n,1)*2)