如何在乳胶的流程图块中绘制S形函数

如何在乳胶的流程图块中绘制S形函数

我如何在流程图块(那些圆圈)内绘制高斯函数符号? 在此处输入图片描述

我的代码是:

\usepackage{tikz}
\usetikzlibrary{arrows.meta,calc,chains,shapes.geometric,backgrounds,fit,arrows,positioning}

\tikzset{
  blockk/.style={
  draw,
  fill=blue!20,
  rectangle,
  minimum height=2.5em,
  minimum width=2.5em
  },
sum/.style={
  draw,
  fill=blue!20,
  circle,
  minimum size=0.5cm,
  },
  neu/.style={
  draw,
  fill=blue!20,
  circle,
  minimum size=0.5cm,
  },
input/.style={coordinate},
output/.style={coordinate},
pinstyle/.style={
  pin edge={to-,thin,black}
  }
}


\begin{figure}
\begin{adjustbox}{width=\textwidth,height=\textheight,keepaspectratio}
\begin{tikzpicture}[auto,>=latex']
    % We start by placing the blocks
    \node [input, name=input1] {};
    %fuzzification
    \node [neu, above = of input1] (neu) {};
    \node [neu, right = of neu] (neu1) {};
    \node [neu, right = of neu1] (neu2) {};
    \node [neu, right = of neu2] (neu3) {};
    %memberships
    \node [neu, above left = 0.5 and 0 of neu] (membership1) {};
    \node [neu, above right = 0.5 and 0 of neu] (membership2) {};
    \node [neu, above left = 0.5 and 0 of neu1] (membership3) {};
    \node [neu, above right = 0.5 and 0 of neu1] (membership4) {};
    \node [neu, above left = 0.5 and 0 of neu2] (membership5) {};
    \node [neu, above right = 0.5 and 0 of neu2] (membership6) {};
    \node [neu, above left = 0.5 and 0 of neu3] (membership7) {};
    \node [neu, above right = 0.5 and 0 of neu3] (membership8) {};
    %Rules firing
    \node [neu, above  = 2.5 of neu] (rule1) {$\bar{z}_l$};
    \node [neu, right = of rule1] (rule2) {$\bar{z}_r$};
    \node [neu, right = of rule2] (rule3) {$\underbar{z}_l$};
    \node [neu, right = of rule3] (rule4) {$\underbar{z}_r$};
    %consequent
    \node [neu, above right = 0.8 and 0.4 of rule2] (consequent) {$O_{f_m}$};
    %sum
    \node [sum, above = of consequent] (sum) {\tiny+};
    %integral
    \node [blockk, above = of sum] (integral) {$D_t^{-q}$};
    %sum1
    \node [sum, above = of integral] (sum1) {};    
    \node[above=-2pt] at (sum1.center){\tiny $+$};
    \node[below=-2pt] at (sum1.center){\tiny $-$};
    %
    \node [input,right = of sum, name=input5] {};
    %
    \node [input,above = of sum1, name=input6] {};
    %
    \node [input,below = of neu1, name=input2] {};
    \node [input,below = of neu2, name=input3] {};
    \node [input,below = of neu3, name=input4] {};
    
    \draw [draw,->] (input1) -- node {\textcolor{blue}{$\tt\hat{y}(t)$}} (neu);
    \draw [draw,->] (input2) -- node {\textcolor{blue}{$\tt\hat{y}(t-\tau)$}} (neu1);
    \draw [draw,->] (input3) -- node {\textcolor{blue}{$\tt\hat{y}(t-2\tau)$}} (neu2);
    \draw [draw,->] (input4) -- node {\textcolor{blue}{$\tt\hat{y}(t-3\tau)$}} (neu3);

    \draw [draw,->] (neu) -- node [left]{$\bar{u}$} (membership1);
    \draw [draw,->] (neu) -- node [right]{$\underbar{u}$} (membership2);
    \draw [draw,->] (neu1) -- (membership3);
    \draw [draw,->] (neu1) -- (membership4);
    \draw [draw,->] (neu2) -- (membership5);
    \draw [draw,->] (neu2) -- (membership6);
    \draw [draw,->] (neu3) -- (membership7);
    \draw [draw,->] (neu3) -- (membership8);

    \draw [draw,->] (membership1) -- (rule1);
    \draw [draw,->] (membership3) -- (rule1);
    \draw [draw,->] (membership5) -- (rule1);
    \draw [draw,->] (membership7) -- (rule1);
    %
    \draw [draw,->] (membership2) -- (rule2);
    \draw [draw,->] (membership4) -- (rule2);
    \draw [draw,->] (membership6) -- (rule2);
    \draw [draw,->] (membership8) -- (rule2);
    %
    \draw [draw,->,red] (membership1) -- (rule3);
    \draw [draw,->,red] (membership3) -- (rule3);
    \draw [draw,->,red] (membership5) -- (rule3);
    \draw [draw,->,red] (membership7) -- (rule3);    
    %
    \draw [draw,->,red] (membership2) -- (rule4);
    \draw [draw,->,red] (membership4) -- (rule4);
    \draw [draw,->,red] (membership6) -- (rule4);
    \draw [draw,->,red] (membership8) -- (rule4);
    %
    \draw [draw,->] (rule1) -- (consequent);
    \draw [draw,->] (rule2) -- (consequent);
    \draw [draw,->] (rule3) -- (consequent);
    \draw [draw,->] (rule4) -- (consequent);
    %
    \draw [draw,->] (consequent) -- (sum);
    %
    \draw [draw,->] (sum) -- (integral);
    %
    \draw [draw,->] (integral) -- (sum1);
    %
    \draw [draw,->] (input5) -- (sum);
    %    
    \draw [draw,->] (input6) -- (sum1);
    %
    \draw[double,dashed,-,green](sum1)--(5.5,11.1)-- ([yshift=-0.5em]consequent.south east);
    
    
\end{tikzpicture}
\end{adjustbox}
\caption{Online identification structure.}\label{fig30}
\end{figure}

答案1

您可以使用picture path选项将绘制的函数放置在节点内:

\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}

\begin{document}
\begin{tikzpicture}

\tikzset{
    neu/.style={
        draw,
        fill=blue!20,
        circle,
        minimum size=0.5cm,
    },
    declare function={
        sigma(\x) = 1/(1+exp(-\x));
    }
}

\node[neu, path picture={
    \draw[shift={(path picture bounding box.center)},
        domain=-0.3:0.3, samples=50,
    ] plot ({\x},{0.3*(sigma(30*\x)-0.5)});
}] (membership1) {};

\end{tikzpicture}
\end{document}

在此处输入图片描述


对于您的具体情况,您可以这样做:

\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}

\begin{document}
\begin{tikzpicture}

\tikzset{
    neu/.style={
        draw,
        fill=blue!20,
        circle,
        minimum size=0.5cm,
    },
    declare function={
        sigma(\x) = 1/(1+exp(-\x));
        sigmap(\x) = sigma(\x)*(1-sigma(\x));
    }
}

\node[neu, path picture={
    \draw[blue, shift={(path picture bounding box.center)},
        domain=-0.25:0.25, samples=50,
    ] plot ({\x},{0.3*(sigma(30*\x-2)-0.5)});
    \draw[blue, shift={(path picture bounding box.center)},
        domain=-0.25:0.25, samples=50
    ] plot ({\x},{0.3*(sigma(20*\x+0.5)-0.5)});
}] at (0,0) (membership1) {};

\node[neu, path picture={
    \draw[blue, shift={(path picture bounding box.center)},
        domain=-0.25:0.25, samples=50,
    ] plot ({\x},{0.3*(sigma(-30*\x-2)-0.5)});
    \draw[blue, shift={(path picture bounding box.center)},
        domain=-0.25:0.25, samples=50
    ] plot ({\x},{0.3*(sigma(-20*\x+0.5)-0.5)});
}] at (2,0) (membership2) {};

\node[neu, path picture={
    \draw[red, shift={(path picture bounding box.center)},
        domain=-0.25:0.25, samples=50,
    ] plot ({\x},{(sigmap(20*\x)-0.1)});
}] at (1,0) (membership3) {};

\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容