在 tikz 中定义一个函数

在 tikz 中定义一个函数

在这个MWE中,Q函数有两个定义:

% 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}

第二个是正确的,但我不明白为什么。有什么帮助吗?

相关内容