答案1
使用 tikz
在这种情况下,我们可以通过\omegac
设置为来改变脉冲的宽度2
。
我们创建两个循环用于放置节点-2\pi
、2\pi
、-\omega_c
,\omega_c
以及一个循环用于绘制脉冲
您可以使用选项缩小图片尺寸scale=0.5
\documentclass[tikz]{standalone}
\def\omegac{2}
\begin{document}
\begin{tikzpicture}
% draw axis
\draw (-10,0)--(10,0)node[below]{$\omega$};
\draw (0,0)--(0,3)node[right]{$H(e^{j\omega})$};
\node [above right]at (0,1){$1$};
% putting nodes -2\pi , 2\pi
\foreach \i/\j in {-2*pi/-2\pi,2*pi/2\pi}
{\draw (\i,0.2)--(\i,0)node[below]{$\j$};}
% draw path for each pulse
\foreach \n in {-2*pi,0,2*pi}
{\draw[thick,blue](\n,0)++(-\omegac,0)--++(0,1)--++(2*\omegac,0)--++(0,-1);}
% putting nodes -\omega_c , \omega_c
\foreach \i/\j in {-\omegac/-,\omegac/}
{\node[below]at(\i,0){$\j\omega_c$};}
\end{tikzpicture}
\end{document}
输出
答案2
我建议你使用pgfplots
;它为您提供了许多有用的功能来绘制图表:
代码:
\documentclass[border=3pt]{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
typeset ticklabels with strut,
width=10cm,
height=3cm,
axis lines=center,
x axis line style={-},
y axis line style={-},
ymax = 3,
xmin=-16,
xmax=16,
xtick={-10,-2,2,10},
xticklabels={$-2\pi$,$-\omega_{c}$,$\omega_{c}$,$2\pi$},
ytick={\empty},
xlabel={$\omega$},
ylabel={$H(e^{j\omega})$},
]
\foreach \Valor in {-10,0,10}
{
\addplot+[ultra thick,black,mark=none,const plot]
coordinates {(\Valor-2,0) (\Valor-2,1) (\Valor+2,0)};
}
\node[above left] at (axis cs:0,1) {1};
\end{axis}
\end{tikzpicture}
\end{document}