I'm trying to plot a normalized sinc function with PGFPlots/TikZ. As this is somewhat tricky because of the limiting value at 0, I used a suggestion provided by percusse.
Here's a minimal example (note that I've renamed the function to sincf
due to conflicts with the rest of the document and inserted an approximation of Pi to normalize):
\documentclass{scrreprt}\usepackage{pgfplots}\pgfplotsset{compat=1.12}\begin{document}\begin{tikzpicture}% https://tex.stackexchange.com/a/235009\pgfmathdeclarefunction{sincf}{1}{% \pgfmathparse{abs(#1)<0.01 ? int(1) : int(0)}% \ifnum\pgfmathresult>0 % \pgfmathparse{1}% \else% \pgfmathparse{sin(3.14159*#1 r)/(3.14159*#1)}% \fi%} \begin{axis} \addplot {sincf(\x)}; \end{axis}\end{tikzpicture}\end{document}
However, I'm getting two errors which I can't figure out:
! Missing = inserted for \ifnum.<to be read again>Yl.23 \addplot plot (\x,{sincf(\x)});I was expecting to see `<', `=', or `>'. Didn't.! Missing number, treated as zero.<to be read again>Yl.23 \addplot plot (\x,{sincf(\x)});A number should have been here; I inserted `0'.(If you can't figure out why I needed to see a number,look up `weird error' in the index to The TeXbook.)
Using MikTeX 2.9