我想使用带有数学函数的 pgfplots,以便以数学方式生成波形。以下是我目前得到的结果:
\documentclass{article}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[domain=-5:5, samples=250,no markers, hide axis,y=1cm,thick]
\addplot {0.3*cos(2*deg(x))}node[right]{$\lambda=1Hz$};
\addplot {0.3*cos(4*deg(x))+1}node[right]{$\lambda=2Hz$};
\addplot {0.3*cos(8*deg(x))+2}node[right]{$\lambda=4Hz$};
\end{axis}
\end{tikzpicture}
\end{document}
欢迎提出想法。
答案1
您可以添加一些随机噪音。
\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.17}
\begin{document}
\begin{tikzpicture}[declare function={a1=0.6;a2=0.3;a3=0.4;}]
\begin{axis}[domain=-5:5, samples=75,no markers, hide axis,y=1cm,thick,
trig format plots=rad,smooth,clip=false]
\addplot[samples=51] {0.3*cos(2*x)*(1+a1*rand)}node[right]{$\lambda=1\,$Hz};
\addplot {0.3*cos(4*x)*(1+a2*rand)+1}node[right]{$\lambda=2\,$Hz};
\addplot {0.3*cos(8*x)*(1+a3*rand)+2}node[right]{$\lambda=4\,$Hz};
\end{axis}
\end{tikzpicture}
\end{document}