[pstricks] Trellis diagrams
Carsten Vogel
texnicer at web.de
Sun Jan 30 09:27:16 CET 2011
Am 29.01.2011 22:25, schrieb Per Ting:
> Is there an easy way to plot the trellis diagrams for convolutional
> codes using PStricks?
psmatrix & multido (needs replicate hack, see header)
I guess this might be a real sophisticated equipement now;
I mean this is really Boz(*), is not is?
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\documentclass[svgnames]{scrartcl}
\usepackage{pst-node}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{multido}
\newcommand{\trbox}[1][00]{\psframebox{#1}}
\def\recur#1{\csname rn#1\recur} \long\def\rnm#1{\endcsname{#1}#1}
\long\def\rn#1{}
\def\replicate#1{\csname rn\expandafter\recur
\romannumeral\number\number#1 000\endcsname\endcsname}
\newpsstyle{tre}{arrows=->,nodesep=.2em,linecolor=Gray}
\newpsstyle{tdashed}{linestyle=dashed}
\newpsstyle{marked}{linecolor=Red,linewidth=2pt,nodesep=.2em,arrows=->}
\begin{document}
%\begin{pspicture}(-.8,-1)(8.8,3.8)
%\psframe[linecolor=Gray,linewidth=.7pt](-.8,-1)(8.8,3.8)
\begin{psmatrix}[colsep=3em,rowsep=1em]
\replicate{4}{\trbox &}\trbox\\
\replicate{4}{\trbox[01] &}\trbox[01]\\
\replicate{4}{\trbox[10] &}\trbox[10]\\
\replicate{4}{\trbox[11] &}\trbox[11]\\
\end{psmatrix}
\multido{\na=1+1,\nb=2+1}{4}{%
\ncline[style=tre]{1,\na}{1,\nb}
\ncline[style=tre]{2,\na}{1,\nb}
\ncline[style=tre]{3,\na}{2,\nb}
\ncline[style=tre]{4,\na}{2,\nb}
\ncline[style=tre,style=tdashed]{1,\na}{3,\nb}
\ncline[style=tre,style=tdashed]{2,\na}{3,\nb}
\ncline[style=tre,style=tdashed]{3,\na}{4,\nb}
\ncline[style=tre,style=tdashed]{4,\na}{4,\nb}
}
\ncline[style=marked]{1,1}{1,2}
\ncline[style=marked]{1,2}{3,3}
\ncline[style=marked]{3,3}{2,4}
\ncline[style=marked]{2,4}{3,5}
%\end{pspicture}
%(*) Thanks to Herbert V., Tobias N., David K., Murray B. [Riptide]
\end{document}
More information about the PSTricks
mailing list