COMPGROUPS.NET | Search | Post Question | Groups | Stream | About | Register

### TikZ: is there is simple way to draw sun of biamry signal and white noise?

• Follow

Hi,
I like illustrate by means of TikZ the sum of binaray and random
signals, for examle 011010 and random signals composed by 16 samples per
bit. I try to achieve this with program below, but results are not
satisfactory -- segments of random function are not conected. Any idea,
how to achieve this or do anyone have idea, how to draw binary signal as
function?

\documentclass{article}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}[
bit/.style = {name=#1,rectangle,draw,thin,
minimum height=5mm,minimum
width=8mm,font=\footnotesize,right=-0.4pt},
nod/.style = {name=#1,%fill=blue!50,
minimum height=5mm,text width=23mm,align=right,
font={\sffamily\bfseries}}
]\small
%-------
\node[bit=b1]                   {0};
\node[bit=b2]   at (b1.east)    {1};
\node[bit=b3]   at (b2.east)    {1};
\node[bit=b4]   at (b3.east)    {0};
\node[bit=b5]   at (b4.east)    {1};
\node[bit=b6]   at (b5.east)    {0};
%-------
\draw[dashed] ([yshift=-2.2] b1.south west) -- + (4.8,0);
\draw[very thick,red]
([yshift=-3.3] b1.south west) -| ++(0.8,2.2) -| ++(1.6,-2.2) -| ++
(0.8,2.2) -| ++(0.8,-2.2) -- ++(0.8,0);
%-------
\foreach \x/\y in {0/-1,0.8/1,1.6/1,2.4/-1,3.2/1,4/-1}
\draw[thick,blue,domain=\x:\x+0.8,samples=16,smooth,variable=\t]
plot (\t,{-2.2 + \y*1.1 + rand});
%-------
\end{tikzpicture}
\end{document}

Regards,
Zarko

 0
Reply zarko.cucej (79) 1/2/2010 12:38:15 PM

Zarko F. Cucej schrieb:
> Hi,
> I like illustrate by means of TikZ the sum of binaray and random
> signals, for examle 011010 and random signals composed by 16 samples per
> bit. I try to achieve this with program below, but results are not
> satisfactory -- segments of random function are not conected. Any idea,
> how to achieve this or do anyone have idea, how to draw binary signal as
> function?
>
> \documentclass{article}
> \usepackage{tikz}
>
> \begin{document}
>     \begin{tikzpicture}[
> bit/.style = {name=#1,rectangle,draw,thin,
>               minimum height=5mm,minimum
> width=8mm,font=\footnotesize,right=-0.4pt},
> nod/.style = {name=#1,%fill=blue!50,
>               minimum height=5mm,text width=23mm,align=right,
> font={\sffamily\bfseries}}
>                         ]\small
> %-------
> \node[bit=b1]                   {0};
> \node[bit=b2]   at (b1.east)    {1};
> \node[bit=b3]   at (b2.east)    {1};
> \node[bit=b4]   at (b3.east)    {0};
> \node[bit=b5]   at (b4.east)    {1};
> \node[bit=b6]   at (b5.east)    {0};
> %-------
>     \draw[dashed] ([yshift=-2.2] b1.south west) -- + (4.8,0);
>     \draw[very thick,red]
>     ([yshift=-3.3] b1.south west) -| ++(0.8,2.2) -| ++(1.6,-2.2) -| ++
>     (0.8,2.2) -| ++(0.8,-2.2) -- ++(0.8,0);
> %-------
>     \foreach \x/\y in {0/-1,0.8/1,1.6/1,2.4/-1,3.2/1,4/-1}
> \draw[thick,blue,domain=\x:\x+0.8,samples=16,smooth,variable=\t]
>     plot (\t,{-2.2 + \y*1.1 + rand});
> %-------
>     \end{tikzpicture}
> \end{document}
>
>
> Regards,
>     Zarko

Could the tikz-timing package be useful?

"This package provides macros and an environment to generate timing
diagrams (digital waveforms) without much effort.  The TikZ package is
used to produce the graphics.  The diagrams may be inserted into text
(paragraphs, \hbox, etc.) and into tikzpictures.  A tabular-like
environment is provided to produce larger timing diagrams."

Uwe

 0
Reply Uwe 1/2/2010 2:16:20 PM

On 2.1.2010 15:16, Uwe Ziegenhagen wrote:
> Zarko F. Cucej schrieb:
>> Hi,
>> I like illustrate by means of TikZ the sum of binaray and random
>> signals, for examle 011010 and random signals composed by 16 samples
>> per bit. I try to achieve this with program below, but results are not
>> satisfactory -- segments of random function are not conected. Any
>> idea, how to achieve this or do anyone have idea, how to draw binary
>> signal as function?
>>
>> \documentclass{article}
>> \usepackage{tikz}
>>
>> \begin{document}
>> \begin{tikzpicture}[
>> bit/.style = {name=#1,rectangle,draw,thin,
>> minimum height=5mm,minimum width=8mm,font=\footnotesize,right=-0.4pt},
>> nod/.style = {name=#1,%fill=blue!50,
>> minimum height=5mm,text width=23mm,align=right,
>> font={\sffamily\bfseries}}
>> ]\small
>> %-------
>> \node[bit=b1] {0};
>> \node[bit=b2] at (b1.east) {1};
>> \node[bit=b3] at (b2.east) {1};
>> \node[bit=b4] at (b3.east) {0};
>> \node[bit=b5] at (b4.east) {1};
>> \node[bit=b6] at (b5.east) {0};
>> %-------
>> \draw[dashed] ([yshift=-2.2] b1.south west) -- + (4.8,0);
>> \draw[very thick,red]
>> ([yshift=-3.3] b1.south west) -| ++(0.8,2.2) -| ++(1.6,-2.2) -| ++
>> (0.8,2.2) -| ++(0.8,-2.2) -- ++(0.8,0);
>> %-------
>> \foreach \x/\y in {0/-1,0.8/1,1.6/1,2.4/-1,3.2/1,4/-1}
>> \draw[thick,blue,domain=\x:\x+0.8,samples=16,smooth,variable=\t]
>> plot (\t,{-2.2 + \y*1.1 + rand});
>> %-------
>> \end{tikzpicture}
>> \end{document}
>>
>>
>> Regards, Zarko
>
> Could the tikz-timing package be useful?
>
> "This package provides macros and an environment to generate timing
> diagrams (digital waveforms) without much effort. The TikZ package is
> used to produce the graphics. The diagrams may be inserted into text
> (paragraphs, \hbox, etc.) and into tikzpictures. A tabular-like
> environment is provided to produce larger timing diagrams."
>
> Uwe

Uwe,
hank you for hint. I will look it.

Regards,
Zarko

 0
Reply Zarko 1/2/2010 2:28:58 PM

Am 02.01.2010 13:38, schrieb Zarko F. Cucej:

> I like illustrate by means of TikZ the sum of binaray and random
> signals, for examle 011010 and random signals composed by 16 samples per
> bit. I try to achieve this with program below, but results are not
> satisfactory -- segments of random function are not conected. Any idea,
> how to achieve this or do anyone have idea, how to draw binary signal as
> function?

The same with PSTricks
the image can be seen here http://perce.de/temp/xx.png

Herbert

\documentclass{article}

\begin{document}

\newlength\xPos\newlength\XPos
\pspicture(0,-5)(10,5)
\psforeach{\xA}{0,1,1,0,1,0}{%
\psline[linecolor=red]%
(0,-0.1)(0.8,-0.1)(0.8,2.2)(2.4,2.2)(2.4,-0.1)(3.2,-0.1) %
(3.2,2.2)(4,2.2)(4,-0.1)(4.8,-0.1)
\pstVerb{usertime srand}
\pscustom[linecolor=blue,plotpoints=20]{
\psplot{0}{0.8}{-3.3 Rand 3 mul add}
\psplot[plotpoints=40]{0.8}{2.4}{-2 Rand 3 mul add}
\psplot{2.4}{3.2}{-3.3 Rand 3 mul add}
\psplot{3.2}{4}{-2 Rand 3 mul add}
\psplot{4}{4.8}{-3.3 Rand 3 mul add}
}
\endpspicture
\end{document


 0
Reply Herbert 1/2/2010 3:36:44 PM

On 2.1.2010 16:36, Herbert Voss wrote:
> Am 02.01.2010 13:38, schrieb Zarko F. Cucej:
>
>> I like illustrate by means of TikZ the sum of binaray and random
>> signals, for examle 011010 and random signals composed by 16 samples per
>> bit. I try to achieve this with program below, but results are not
>> satisfactory -- segments of random function are not conected. Any idea,
>> how to achieve this or do anyone have idea, how to draw binary signal as
>> function?
>
> The same with PSTricks
> the image can be seen here http://perce.de/temp/xx.png
>
> Herbert
>
> \documentclass{article}
>
> \begin{document}
>
> \newlength\xPos\newlength\XPos
> \pspicture(0,-5)(10,5)
> \psforeach{\xA}{0,1,1,0,1,0}{%
>    \advance\XPos by 8mm\psTextFrame(\xPos,0)(\XPos,5mm){\xA}%
>    \advance\xPos by 8mm}
> \psline[linecolor=red]%
>    (0,-0.1)(0.8,-0.1)(0.8,2.2)(2.4,2.2)(2.4,-0.1)(3.2,-0.1) %
>    (3.2,2.2)(4,2.2)(4,-0.1)(4.8,-0.1)
> \pstVerb{usertime srand}
> \pscustom[linecolor=blue,plotpoints=20]{
>    \psplot{0}{0.8}{-3.3 Rand 3 mul add}
>    \psplot[plotpoints=40]{0.8}{2.4}{-2 Rand 3 mul add}
>    \psplot{2.4}{3.2}{-3.3 Rand 3 mul add}
>    \psplot{3.2}{4}{-2 Rand 3 mul add}
>    \psplot{4}{4.8}{-3.3 Rand 3 mul add}
> }
> \endpspicture
> \end{document
>

Dear Herbert,
results of above program is what i like! Since I'm not familiar with
PSTrick, I faced with new learning process to be able understand the
program  ... but it seems to be worth!

Thank you very much! Regards,
Zarko

 0
Reply Zarko 1/2/2010 9:12:20 PM

Hi,

With the latest CVS version, one can do something like this in TikZ as
follows:

\documentclass{article}
\usepackage{tikz}
\begin{document}

\def\outputs{{0,1,1,0,1,0}}

\begin{tikzpicture}[x=3D0.75cm,y=3D0.25cm]
\foreach \x in {0,...,5}
\node
[
rectangle,
draw,
minimum width=3D0.75cm,
minimum height=3D0.5cm,
anchor=3Dsouth west,
]
at (\x,0)
{\pgfmathparse{\outputs[\x]}\pgfmathresult};

\draw [red, yshift=3D-.25cm] (0,0)
\foreach \x in {0,...,5}
{
-- (\x,\outputs[\x]*6) -- (\x+1,\outputs[\x]*6)
};

\draw [blue,yshift=3D-3cm]  (0,-1)
\foreach \x in {0,...,5}
{
-- (\x,\outputs[\x]*6)
\foreach \i in {0,0.025,...,1}
{
-- (\x+\i,\outputs[\x]*6+rand*3)
}
};

\end{tikzpicture}
\end{document}

Regards

Mark
On Jan 2, 12:38=A0pm, "Zarko F. Cucej" <zarko.cu...@gmail.com> wrote:
> Hi,
> I like illustrate by means of TikZ the sum of binaray and random
> signals, for examle 011010 and random signals composed by 16 samples per
> bit. I try to achieve this with program below, but results are not
> satisfactory -- segments of random function are not conected. Any idea,
> how to achieve this or do anyone have idea, how to draw binary signal as
> function?
>
> \documentclass{article}
> \usepackage{tikz}
>
> \begin{document}
> =A0 =A0 =A0\begin{tikzpicture}[
> bit/.style =3D {name=3D#1,rectangle,draw,thin,
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0minimum height=3D5mm,minimum
> width=3D8mm,font=3D\footnotesize,right=3D-0.4pt},
> nod/.style =3D {name=3D#1,%fill=3Dblue!50,
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0minimum height=3D5mm,text width=3D23mm,ali=
gn=3Dright,
> font=3D{\sffamily\bfseries}}
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0]\small
> %-------
> \node[bit=3Db1] =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 {0};
> \node[bit=3Db2] =A0 at (b1.east) =A0 =A0{1};
> \node[bit=3Db3] =A0 at (b2.east) =A0 =A0{1};
> \node[bit=3Db4] =A0 at (b3.east) =A0 =A0{0};
> \node[bit=3Db5] =A0 at (b4.east) =A0 =A0{1};
> \node[bit=3Db6] =A0 at (b5.east) =A0 =A0{0};
> %-------
> =A0 =A0 =A0\draw[dashed] ([yshift=3D-2.2] b1.south west) -- + (4.8,0);
> =A0 =A0 =A0\draw[very thick,red]
> =A0 =A0 =A0([yshift=3D-3.3] b1.south west) -| ++(0.8,2.2) -| ++(1.6,-2.2)=
-| ++
> =A0 =A0 =A0(0.8,2.2) -| ++(0.8,-2.2) -- ++(0.8,0);
> %-------
> =A0 =A0 =A0\foreach \x/\y in {0/-1,0.8/1,1.6/1,2.4/-1,3.2/1,4/-1}
> \draw[thick,blue,domain=3D\x:\x+0.8,samples=3D16,smooth,variable=3D\t]
> =A0 =A0 =A0plot (\t,{-2.2 + \y*1.1 + rand});
> %-------
> =A0 =A0 =A0\end{tikzpicture}
> \end{document}
>
> Regards, =A0 =A0 =A0 =A0
> =A0 =A0 =A0 =A0 Zarko


 0
Reply vibrovski 1/3/2010 4:14:48 PM

5 Replies
538 Views

(page loaded in 0.076 seconds)

Similiar Articles:

7/24/2012 11:38:55 AM