过滤器的规格面罩

过滤器的规格面罩

我想用 tikz 包为带通滤波器绘制一个规范蒙版,但是我对此完全陌生,并且我必须绘制的所有滤波器都有相似的形状,所以如果有人能帮忙,我将不胜感激。

我想要的形状如下:在此处输入图片描述

答案1

也许这能有所帮助。我使用了 Tikz \filldraw,因为pgfplots \addplot我不确定如何为区域使用不同的基值。也许更有pgfplots经验的人可以提供帮助。

\documentclass[tikz]{standalone}

\usepackage{pgfplots}

\usetikzlibrary{patterns}

\begin{document}
    \begin{tikzpicture}
        \def\alphap{0.1}
        \def\alphaaone{0.8}
        \def\alphaatwo{1}

        \def\omegaaone{1}
        \def\omegapone{2}
        \def\omegaptwo{3}
        \def\omegaatwo{6}

        \begin{axis}[
            scale only axis,
            axis lines=middle,
            width = 10cm,
            height = 5cm,
            ymin = 0,
            ymax = 1.2,
            xmin = 0,
            xmax = 8,
            xtick = {\omegaaone,\omegapone,\omegaptwo,\omegaatwo},
            xticklabels = {$ \omega'_{a1} $,$ \omega'_{p1} $,$ \omega'_{p2} $,$ \omega'_{a2} $},
            ytick = {\alphap,\alphaaone,\alphaatwo},
            yticklabels = {$ \alpha_p $,$ \alpha_{a1} $,$ \alpha_{a2} $},
            xlabel = {$ \omega' $},
            ylabel = {$ \alpha(\omega') $},
            every axis x label/.style={at={(current axis.right of origin)},anchor=north east},
            every axis y label/.style={at={(current axis.above origin)},anchor=north east}
        ]
            \addplot[draw=none] coordinates {(0,0)};

            \begin{scope}[pattern = north east lines, pattern color = gray,line width = 1pt]
                \filldraw (axis cs:-0.1,-0.1) rectangle (axis cs:\omegaaone,\alphaaone);
                \filldraw (axis cs:\omegapone,1.3) rectangle (axis cs:\omegaptwo,\alphap);
                \filldraw (axis cs:\omegaatwo,-0.1) rectangle (axis cs:8.1,\alphaatwo);
            \end{scope}
        \end{axis}
    \end{tikzpicture}
\end{document}

我用了这个答案将 x 和 y 标签放在轴的另一侧。

结果是:

在此处输入图片描述

答案2

这是 tikz 中的解决方案。更改循环中的四个坐标\foreach以更改行为。图形被标准化为(1,1)位于右上角。

\documentclass[border=5mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{patterns,calc}
\begin{document}
\begin{tikzpicture}[x=8cm,y=4cm]
  \draw[-stealth](0,0)--(1,0) node[below]{$\omega'$};
  \draw[-stealth](0,0)--(0,1) node[left]{$a(\omega')$};
  \foreach \x/\y [count=\ind] in {0.2/0.7,0.3/0.2,0.4/0.2,0.7/0.9}{% Corners in the filter def
    \coordinate (Corner-\ind) at (\x,\y);
  }
  \path [pattern=north east lines](0,0) rectangle (Corner-1);
  \path [pattern=north east lines](Corner-2) rectangle (Corner-3 |- {(1,1)});
  \path [pattern=north east lines](Corner-4) rectangle (1,0);
  \draw[thick] (Corner-1 -| {(0,0)}) -| (Corner-1 |- {(0,0)});
  \draw[thick] (Corner-2 |- {(0,1)}) -- (Corner-2) -| (Corner-3 |- {(0,1)});
  \draw[thick] (Corner-4 -| {(1,0)}) -| (Corner-4 |- {(1,0)});  
  %% Draw tick marks
  \draw (Corner-1 |- {(0,1mm)}) -- +(0,-2mm) node[below]{$\omega'_{a1}$};
  \draw (Corner-2 |- {(0,1mm)}) -- +(0,-2mm) node[below]{$\omega'_{p1}$};
  \draw (Corner-3 |- {(0,1mm)}) -- +(0,-2mm) node[below]{$\omega'_{p2}$};
  \draw (Corner-4 |- {(0,1mm)}) -- +(0,-2mm) node[below]{$\omega'_{a2}$};
  \draw (Corner-1 -| {(0,1mm)}) -- +(-2mm,0) node[left]{$\alpha_{a1}$};
  \draw (Corner-2 -| {(0,1mm)}) -- +(-2mm,0) node[left]{$\alpha_p$};
  \draw (Corner-4 -| {(0,1mm)}) -- +(-2mm,0) node[left]{$\alpha_{a2}$};
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容