how to plot random ones and zeros as sequare wave?
Show older comments
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

Accepted Answer
More Answers (1)
Wayne King
on 9 Mar 2013
It is better to use stem() for this purpose
s=rand(1,10)>0.5;
t=1:1:10;
stem(t,s,'markerfacecolor',[0 0 1])
Categories
Find more on Signal Processing Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!