1

The below figure shows large scale and small scale fading concepts in communication.

1

Please also see my MWE:

\documentclass[borders=1mm]{standalone}

\usepackage[usenames,dvipsnames]{xcolor}

\usepackage{tikz}
\usetikzlibrary{calc,shapes}

\makeatletter
\pgfmathdeclarefunction{invgauss}{2}{%
  \pgfmathln{#1}% <- might need parsing
  \pgfmathmultiply@{\pgfmathresult}{-2}%
  \pgfmathsqrt@{\pgfmathresult}%
  \let\@radius=\pgfmathresult%
  \pgfmathmultiply{6.28318531}{#2}% <- might need parsing
  \pgfmathdeg@{\pgfmathresult}%
  \pgfmathcos@{\pgfmathresult}%
  \pgfmathmultiply@{\pgfmathresult}{\@radius}%
}

\pgfmathdeclarefunction{randnormal}{0}{%
  \pgfmathrnd@
  \ifdim\pgfmathresult pt=0.0pt\relax%
    \def\pgfmathresult{0.00001}%
  \fi%
  \let\@tmp=\pgfmathresult%
  \pgfmathrnd@%
  \ifdim\pgfmathresult pt=0.0pt\relax%
    \def\pgfmathresult{0.00001}%
  \fi
  \pgfmathinvgauss@{\pgfmathresult}{\@tmp}%
}
\makeatother

\begin{document}
\begin{tikzpicture}

\draw[-latex](0,0)--++(6.75,0);
\draw[-latex](0,0)--++(0,5.5);

\draw[domain=0:6.25,smooth,variable=\x,Blue] plot ({\x},{-0.8*\x+5});
\draw[domain=0:6.25,smooth,variable=\x,Green] plot ({\x},{(-0.8*\x+5)+0.6*randnormal});

\end{tikzpicture}
\end{document}

This is the output: enter image description here

How can I add small scale effect to my plot with Tikz?

1

This is a solution using pgfplots.

  • I used sin(150*x)+cos(110*x)+cos(220*x) as the large scale effect function.
  • For small scale effect, rnd*sin(5000*x) function is used. rnd returns a random value between 0 and 1.

enter image description here

Code:

\documentclass[border=1cm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}

\begin{document}

\begin{tikzpicture}
\begin{axis}
\addplot[domain=0:6.25,red] {-0.8*x+5};
\addplot[domain=0:6.25,black,samples=300,smooth,dashed] {-0.8*x+5+sin(150*x)+cos(110*x)+cos(220*x)};
\addplot[domain=0:6.25,blue,samples=300,smooth] {-0.8*x+5+sin(150*x)+cos(110*x)+cos(220*x)+0.3*rnd*sin(5000*x)};
\end{axis}
\end{tikzpicture}

\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.