I want to draw a simple graphical example of a convolution of two discrete sequences in TikZ. I used the code from this link to get my result, which is already what I want but, so far, the values of the different signals at the different time instants are just numbers computed somewhere else.

I'm curious to know if there is an easy way to define two variables for the two sequences and compute the convolution signal, i.e. enter image description here directly in TikZ.


    standard/.style={%Axis format configuration
        axis x line=middle,
        axis y line=middle,
        enlarge x limits=0.15,
        enlarge y limits=0.15,
        every axis x label/.style={at={(current axis.right of origin)},anchor=north west},
        every axis plot post/.style={mark options={fill=white}},
        xticklabel style={align=center},
        xmin=-0.5, xmax=6,
        ymin=0, ymax=2,
        group style={
        group size=3 by 1,
        vertical sep=25pt,
        horizontal sep=35pt
    % Plot [1, 1]
    \addplot+[ycomb,black,thick] plot coordinates {(0,1) (1,0.5) (2,1) (3,1)};
    % Plot [1, 2]
    \addplot+[ycomb,black,thick] plot coordinates {(0,1) (1,0.5) (2,0.25)};
    % Plot [1, 3]
    title={$c[n] = a[n]\ast b[n]$},
    \addplot+[ycomb,black,thick] plot coordinates {(0,1) (1,1) (2,1.5) (3,1.625) (4,0.75) (5,0.25)};    

enter image description here

  • 2
    It would be a one liner if you escape to python or lua though
    – percusse
    Sep 8, 2016 at 17:20
  • 1
    @percusse, could you show us how you would do that using lua? Dec 11, 2016 at 12:42


You must log in to answer this question.

Browse other questions tagged .