MATLAB: How to plot random ones and zeros as sequare wave

plot bits

i am trying to plot my random binary signal as square wave using these simple code
s=rand(1,10)>0.5;
t=1:1:10;
plot(t,s);
but its appear as triangle wave as shown below

Best Answer

n=20
s=rand(1,n)>0.5;
s=repmat(s',1,100)'
s=s(:)'
t=linspace(0,n,numel(s))
plot(t,s,'r')
Related Question