How to use 'randi' in MATLAB to generate equally probable samples which are either 0 or 1? [closed]

How can I use ‘randi’ function in MATLAB to generate a signal sequence s(t) which contains 1e6 samples which are either 0 or 1 and are equally probable. Any suggestions? Thanks!

• Hint: if you have integers in the range X to Y, how can you convert them to numbers in the range X+Z to Y+Z?
– MBaz
Apr 17, 2021 at 16:07
• For a binary sequence you can also use "logicals" instead of integer type. x = rand(n,1) > 0.5;  would do it. Apr 17, 2021 at 16:29
• The answer is randi([0, 1], numSamples, 1);.
– Royi
Apr 24, 2021 at 11:52

• You could do it much simpler (Directly) by randi([0, 1], numSamples, 1);.