1

In this MWE there are two definitions of Q function:

% arara: lualatex: {synctex: yes, shell: yes}

\documentclass[border=5mm]{standalone}

\usepackage{pgfplots}

\pgfplotsset{compat=newest}

\def\qfuncta(#1){0.5*erfc(#1/sqrt(2))}
\def\qfunctb(#1)(#2){0.5*erfc(#1/sqrt(2))}

\begin{document}
\begin{tikzpicture}
\begin{semilogyaxis}[
log plot exponent style/.style={/pgf/number format/precision=1},
samples=1000,
width=10cm, height=8cm,enlargelimits=false,
grid, yminorgrids,  
xmin=0, xmax=15, xlabel={$x$ (dB)}, xtick={0,2,...,14}, xticklabels={$0$,$2$,$4$,$6$,$8$,$10$,$12$,$14$},
ymax=1, ymin=0.000000001, ylabel={$Q\left({\sqrt{x}}\right)$}]

\addplot [line width=1pt, color=blue, domain=0:15] gnuplot{\qfuncta(sqrt(10^(0.1*x)))} ;
\end{semilogyaxis}
\end{tikzpicture}

\begin{tikzpicture}
\begin{semilogyaxis}[
log plot exponent style/.style={/pgf/number format/precision=1},
samples=1000,
width=10cm, height=8cm,enlargelimits=false,
grid, yminorgrids,  
xmin=0, xmax=15, xlabel={$x$ (dB)}, xtick={0,2,...,14}, xticklabels={$0$,$2$,$4$,$6$,$8$,$10$,$12$,$14$},
ymax=1, ymin=0.000000001, ylabel={$Q\left({\sqrt{x}}\right)$}]
\addplot [line width=1pt, color=blue, domain=0:15] gnuplot{\qfunctb(sqrt(10^(0.1*x)))()} ;
\end{semilogyaxis}
\end{tikzpicture}

\end{document}

the second one is the correct but I don't understand why. Any help?

  • I don't know how \def works, but with \newcommand{\qfuncta}[1]{0.5*erfc(#1/sqrt(2))} and gnuplot{\qfuncta{sqrt(10^(0.1*x))}};, or just gnuplot{0.5*erfc(sqrt(10^(0.1*x))/sqrt(2))};, I obtain similar results to your use of \qfunctb. – Ignasi Apr 09 '15 at 14:45
  • \def does not attempt to balance the (), it just grabs the first ( and the first ) and lets whatever is between them be #1. – John Kormylo Apr 10 '15 at 04:32
  • In addition to @JohnKormylo: You have to write \qfuncta({sqrt(10^(0.1*x))}) to resolve this problem. – Henri Menke Apr 12 '15 at 16:56
  • @Henri Menke Thanks. Now I understand the solution.(+1) – jpayansomet Apr 16 '15 at 18:47

0 Answers0