尝试绘制以下内容:
使用此代码:
\documentclass[a4paper]{article}
\usepackage{pgfplots}
\usetikzlibrary{math} % defining sinc(x).
\pgfplotsset{compat=1.14}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
xlabel = $k$,
ylabel = $E(k)$,
title = {Periodic Brillouin zone},
xmin = -3.5*pi, xmax = 3.5*pi,
]
\tikzmath{
function sinc(\x) {
if abs(\x) < 0.001 then {
return 1.0;
} else {
return sin(\x r)/\x;
};
};
}
\addplot3[
domain = -3*pi : 3*pi,
domain y = 0.1 : 3.5,
contour gnuplot = {levels = {0}, labels=false,},
samples = 99,
samples y = 99,
] { cos(x) - 5*sinc( 5.12*sqrt(y) ) - cos( 5.12*sqrt(y) ) };
\end{axis}
\end{tikzpicture}
\end{document}
但我收到了这个错误信息:
非法测量单位(插入 pt)。Y
l.31
...c( 5.12*sqrt(y) ) - cos( 5.12*sqrt(y) ) };
我无法解码。我做错了什么?
注意:我已尝试在函数参数上使用deg(x)
(乘以)。pi
第一个图是使用以下 MATLAB 代码制作的:
[X, Y] = meshgrid(linspace(-3*pi, 3*pi, 99), linspace(0.1, 3.5, 99));
Z = cos(X) - ( 5*pi*sinc( 5.12 * sqrt(Y) / pi ) ) - cos( 5.12 * sqrt(Y) );
contour(X, Y, Z, [0,0]);
for i = 1 : 3
line( i * [pi, pi], [0, 3.5], 'color', 'k', 'linestyle', '--');
line( i * [-pi, -pi], [0, 3.5], 'color', 'k', 'linestyle', '--');
end
xlabel('k')
xlim( [ -(N+0.5)*pi, (N+0.5)*pi ] )
set (gca, 'xtick', [-3*pi -2*pi -pi 0 pi 2*pi 3*pi])
set (gca, 'xticklabel', {'-3\pi/a','-2\pi/a','-\pi/a','0','\pi/a','2\pi/a','3\pi/a',})
ylabel('E(k)')