[fr] La 1ere figure ci-dessous permet de représenter la conversion analogique numérique avec \NN le nombre de niveaux, réalisée avec le code suivant (il faut autoriser gnuplot). Comme vous pouvez le constater, la deuxième figure n'est pas complète, la seule différence est dans l'appel de la fonction, dans la seconde, j'ai généralisée en précisant \NN
[en] The first figure below is used to represent the analog to digital conversion with \NN the number of levels, performed with the following code (you have to allow gnuplot). As you can see, the second figure is not complete, the only difference is in the function call in the second, I generalized by specifying \NN
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning,fit}
\begin{document}
\begin{tikzpicture}
\def\NN{16}
\begin{scope}[xscale=6,yscale=2]
\draw[draw=red,,fill=pink] plot[id=sin9c,prefix=gnuplot/,domain=0:2,samples=60,
ybar interval]
function{0.25*floor(\NN/4*(sin(4*x)+0.5*sin(20*x)+0.05*sin(200*x)+0.03*sin(400*x)+2))};
\draw[color=blue,thick] plot[id=sin7c,prefix=gnuplot/,domain=0:2,samples=1000,thick]
function{sin(4*x)+0.5*sin(20*x)+0.05*sin(200*x)+0.03*sin(400*x)+2};
\foreach \nn in{0,1,2,...,\NN}{
\draw (0,{2*\nn/(\NN/2)}) node[left]{\small \nn}-- (2,{2*\nn/(\NN/2)});
}
\draw (0,0) -- (0,4);
\end{scope}
\end{tikzpicture}
\begin{tikzpicture}
\def\NN{16}
\begin{scope}[xscale=6,yscale=2]
\draw[draw=red,,fill=pink] plot[id=sin9c,prefix=gnuplot/,domain=0:2,samples=60,
ybar interval]
function{4/\NN*floor(\NN/4*(sin(4*x)+0.5*sin(20*x)+0.05*sin(200*x)
+0.03*sin(400*x)+2))};
\draw[color=blue,thick] plot[id=sin7c,prefix=gnuplot/,domain=0:2,samples=1000,thick]
function{sin(4*x)+0.5*sin(20*x)+0.05*sin(200*x)+0.03*sin(400*x)+2};
\foreach \nn in{0,1,2,...,\NN}{
\draw (0,{2*\nn/(\NN/2)}) node[left]{\small \nn}-- (2,{2*\nn/(\NN/2)});
}
\draw (0,0) -- (0,4);
\end{scope}
\end{tikzpicture}
\end{document}

Comment faire pour obtenir la courbe? / How to obtain the curve?