我正在尝试绘制以下 Fejer 内核:
((sin(7x/2)^2)/(sin(x/2)^2))*(1/16)
。
下面是我尝试过的代码,但不知为何一直出错。有人能告诉我为什么这不起作用并帮我在 Tikz 中绘制它吗?非常感谢!
\begin{center}
\begin{figure}
\centering
\begin{tikzpicture}
\begin{axis}[width=88mm,
axis lines=middle,
axis line style = {->},
axis on top,
trig format=rad,
xmin=-10.5, xmax=10.5,
xtick={-10,-8,-6,-4,-2,...,10},
tick label style={font=\footnotesize, inner sep=2pt},
xlabel={$x$}, x label style={anchor=west},
ymin=-0.5, ymax=1.1,
ylabel={$y$}, y label style={anchor=south},
domain=-10:10, samples=200
]
\addplot [thick,black!80] {((sin(7x/2)^2)/(sin(x/2)^2))*(1/16)};
\end{axis}
\end{tikzpicture}
\caption{Caption}
\end{figure}
\end{center}
提前致谢!
另外,对于我在这个问题上写的代码不太好,我深表歉意。我见过其他人很好地展示了它,但我不知道该怎么做。
答案1
尝试此代码(在函数中进行更正以绘制!):
\documentclass[border=15pt]{standalone}
\usepackage{tikz,pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[width=88mm,
axis lines=middle,
axis line style = {->},
axis on top,
trig format=rad,
xmin=-10.5, xmax=10.5,
xtick={-10,-8,-6,-4,-2,...,10},
tick label style={font=\footnotesize, inner sep=2pt},
xlabel={$x$}, x label style={anchor=west},
ymin=-0.5, ymax=1.1,
ylabel={$y$}, y label style={anchor=south},
domain=-10:10, samples=200
]
\addplot[thick,black!80] {((sin(7*x/2)^2)/(sin(x/2))^2)*(1/14)*1/pi};
\end{axis}
\end{tikzpicture}
\end{document}
输出: