5

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:

\documentclass{beamer}
\usepackage{tikz}
\begin{document}
\begin{frame}{Grid+Irregular wave}
\begin{center}
\begin{tikzpicture}
    \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);
 \end{tikzpicture}
 \end{center}
 \end{frame}
 \end{document}
  • 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
7

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

\documentclass[tikz]{standalone}
\begin{document}
\begin{tikzpicture}
\draw (0,0) --(1,0)|- ++(rnd,1)
     \foreach \x in {1,...,10}{-|++(rnd,-1) -| ++(rnd,1)}
     -| ++(rnd,-1);
\end{tikzpicture}
\end{document}

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.