how to plot random ones and zeros as sequare wave?

1 visualización (últimos 30 días)
Abdu
Abdu el 9 de Mzo. de 2013
Comentada: ali al-khayyat el 24 de Ag. de 2019
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

Respuesta aceptada

Azzi Abdelmalek
Azzi Abdelmalek el 9 de Mzo. de 2013
Editada: Azzi Abdelmalek el 9 de Mzo. de 2013
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')
  1 comentario
ali al-khayyat
ali al-khayyat el 24 de Ag. de 2019
Excuse me, could you help me to generate triangle signal starts from 0 to 60 degree and stops and then starts from 120 to 180 and then repeat itself, either by coding or simulink, please?

Iniciar sesión para comentar.

Más respuestas (1)

Wayne King
Wayne King el 9 de Mzo. de 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])

Categorías

Más información sobre Audio I/O and Waveform Generation en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by