[Xy-pic] Diagrams of digital LTI filter

Richard Lewis xypic at rtf.org.uk
Thu Jul 31 01:36:22 CEST 2003


Nicolas Ratier <nicolas.ratier at lpmo.edu> writes:

> I'm preparing a course on Digital Signal Processing.
> I have to draw diagrams of digital LTI filter on the form :
>
>                            z
>                 X o-->--o-->--o
>                         |     |
>                       h |     |
>                         o-->--o-->--o Y
>
> I don't succeed in doing 3 things :

>        + Write an array at the center of the line : i.e.  -->--
>          (horizontally and vertically)

Before i discovered xygraph, I used to use

\def\armid[#1]{\ar@{-}[#1]|<>(.6){\object@{>}}}

in \xymatrix. Here #1 can be any `hop', so \armid[rd] will be a diagonal arrow with
a -->-- in the middle.

Thus you could say:

\newcommand{\Xr}{\ar@{-}[r]}
\newcommand{\Xd}{\ar@{-}[d]}
\newcommand{\Xv}{*\txt{ }}

\def\armid[#1]{\ar@{-}[#1]|<>(.6){\object@{>}}} 


\entrymodifiers={+[o][F-]}

\xymatrix{
\armid[r] & \armid[r]^{z^{-1}} \armid[d]^{h_{0}} & \armid[d]^{h_{1}} & \Xv \\
 \Xv      & \armid[r]                            & \armid[r]         & \;\\
}



>        + Write the letter X to the left of the node
>          (idem for Y to the right of the node)

I dont know how to do this with \xymatrix, thought i expect it is
possible.  With \xygraph it is not too hard:


%first define !Z#1#2 to set the scale of the diagram. #1 affects the
%width, #2 the height
\newgraphescape{Z}#1#2{!{0;<#1,0pc>:<0pc,#2>::0}}

\xygraph{!Z{4em}{4em}
         !~*{+[o][F-]}
         !~-{@{-}|<>(.6){\object@{>}}}
%here comes the complicated bit.
%the {} groups represent nodes
          {}="start"-[r] {}(? -^{z^{-1}}[r] {} -^{h1}[d] {}="a",
                            ? -^{h_0}   [d]{}="b")
                           "b"-"a" -[r] {}="end"
             %here we add `X' before the "start" node
                "start"!{"start"+L*+!R{X}}
             %here we add `Y' to right of the "end" node
              "end"!{"end"+R*+!L{Y}}}


The above looks unreadable, but with practice (read
<ftp://ftp.diku.dk/diku/semantics/papers/D-210.ps.Z> and all will
become clear) it isnt so hard.

roughly:
the !Z stuff just sets the dimensions

the !~* stuff does the same as \entrymodifiers, but in an xygraph, if
we say !{...} then we can override the entrymodifiers and hence get an
unframed X and Y.

the !~- stuff makes `-' draw an `\armid' type label

in the actual diagram:

 {} is the same as your \Xv, ie an empty object
(that will get a +[o][F-] frame from the !~* setting).  So the first
empty node is named "start"

 [r] means we move right from the current position; -[r] {} means we draw
 an arrow to an empty node to the right of our current position.

the  (? ...[r] ,
      ? ...[d]  ) construction draws 
  1. the upper then right-hand edge
  2. the left edge
of the square

the `"a"-"b"' does the bottom edge of the square

the `"start"!{"start"+L*+!R{X}}' puts an X to the left of the "start" node.




>        + Write black and white circle and set the radius
>

page 26 of the reference manual might be what you need here?


> With such an example, I can draw almost all the LTI filter.
> (And release a LaTeX/xy-pix filter library)
>
> Many thanks,
> Nicolas
>
> -------------------------------------------------------
> \documentclass{article}
>
> \usepackage[all,2cell,ps]{xy}
>
> \begin{document}
>
> \newcommand{\Xr}{\ar@{-}[r]}
> \newcommand{\Xd}{\ar@{-}[d]}
> \newcommand{\Xv}{*\txt{ }}
>
> \entrymodifiers={+[o][F-]}
> \xymatrix{
> \Xr & \Xr^{z^{-1}} \Xd^{h_{0}} & \Xd^{h_{1}} & \Xv    \\
> \Xv & \Xr                      & \Xr         & \, \\
> }
>
> \end{document}
>
> _______________________________________________
> xy-pic mailing list
> http://tug.org/mailman/listinfo/xy-pic



More information about the xy-pic mailing list