[Tex/LaTex] Drawing membership functions and fuzzy sets with LaTeX

diagrams

  1. How can I visualize in LaTeX Fuzzy Logic diagrams such as the following picture?
  2. Also how I can visualize sets?

Is the better way to show Fuzzy diagrams as an image?

enter image description here

Best Answer

One possibility using PGF/TikZ:

\documentclass{article}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
\draw[->] (0,0) -- node[below] {quantized} (4.5,0) node[below] {Age};
\draw[->] (0,0) -- (0,1.5) node[left] {$\mu$};
\node at (-0.2,0) {0};
\node at (-0.2,1) {1};
\draw[fill=yellow] (0,1) -- (4,1) -- (4,0) -- (0,0) -- cycle;
\foreach \x in {0.5,1,1.5,2,2.2,3.4}
  \draw (\x,0) -- (\x,1);
\begin{scope}[xshift=5.5cm]
\draw[->] (0,0) -- node[below] {granulated} (4.5,0) node[below] {Age};
\draw[->] (0,0) -- (0,1.5) node[left] {$\mu$};
\node at (-0.2,0) {0};
\node at (-0.2,1) {1};
\draw[fill=yellow!40] (0,1) -- (1,1) -- (1.75,0) -- (0,0) -- cycle;
\draw[fill=yellow!40] (2.25,0) -- (3,1) -- (4,1) -- (4,0) -- cycle;
\draw[fill=yellow!40] (1.25,0) -- (1.8,1) -- (2.3,1) -- (3,0) -- cycle;
\draw (1,1) -- (1.75,0) -- (2.25,0) -- (3,1);
\node[above,font=\footnotesize] at (0.5,1) {young};
\node[above,font=\footnotesize] at (2,1) {middle-aged};
\node[above,font=\footnotesize] at (3.5,1) {old};
\end{scope}
\node[anchor=south] at (current bounding box.north)
  {\textbullet\ continuous $\rightarrow$ quantized $\rightarrow$ granulated};
\end{tikzpicture}

\end{document}

enter image description here

For your second question (the one about sets), can you please add to your question an image of the kind of image you are trying to produce?