I am new to tikz and am not familiar with nomenclature so please excuse my raw expression here.

I need to say a non-periodic square wave. I saw this post How to draw a square wave? which talks about a periodic sq wave. Right now my solution comprises of drawing individual line segments and that taking too much time.

Is there a faster way of doing this

So Far:

\begin{frame}{Grid+Irregular wave}
    \draw [black] (-5.0,0) -- (-4.75,0);
    \draw [black] (-4.75,0) -- (-4.75,1);
    \draw [black] (-4.75,1) -- (-4.5,1);
    \draw [black] (-4.5,1) -- (-4.5,0);   
    \draw [black] (-4.5,0) -- (-4.0,0);
    \draw [black] (-4.0,0) -- (-4.,1);
    \draw [black] (-4.0,1) -- (-3.0,1);
    \draw [black] (-3.0,1) -- (-3.0,0);    
    \draw [black] (-3.0,0) -- (-2.5,0);
    \draw [black] (-2.5,0) -- (-2.5,1);
    \draw [black] (-2.5,1) -- (-2.0,1);
    \draw [black] (-2.0,1) -- (-2.0,0);
  • Can you show us what you have so far? – Thruston May 23 '15 at 21:10
  • actually, i just want to show a non-periodic wave , so the transitions can be at any random time instance…..so the values that I used in my code are not important for me – NAASI May 23 '15 at 22:52

You can simply randomize the lengths of rising and falling edge locations

\draw (0,0) --(1,0)|- ++(rnd,1)
     \foreach \x in {1,...,10}{-|++(rnd,-1) -| ++(rnd,1)}
     -| ++(rnd,-1);

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.