![PGF 图中的电压图](https://linux22.com/image/299025/PGF%20%E5%9B%BE%E4%B8%AD%E7%9A%84%E7%94%B5%E5%8E%8B%E5%9B%BE.png)
有可能在 PGF 图上实现这一点吗?我可以设法得到正弦波并绘制锯齿波,但无法将它们全部整合在一起
答案1
实现 Jesse 图而不使用循环的另一种方法是使用abs(sin(x))
整流正弦波、exp(-(0.0015*mod(x+90,180))
重复指数函数以及max(<function a>, <function b>)
将两者结合起来:
\documentclass[border=5mm]{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
domain=0:1.5*360,
samples=4*360,
xtick=\empty,
width=10cm, height=4cm,
ymin=0,
enlarge x limits=false
]
\addplot [densely dashed] {abs(sin(x))};
\addplot [very thick] {max(abs(sin(x)), exp(-(0.0015*mod(x+90,180)))};
\end{axis}
\end{tikzpicture}
\end{document}
答案2
这是通过 PGFplots 实现的一种可能解决方案。整流曲线是具有较大时间常数的指数衰减函数,而不是倾斜线。
代码
\documentclass{article}
\usepackage{pgfplots}
\usepackage{graphicx}
\begin{document}
\def\arch{1.7*pi/3} %
\begin{figure}[!hbt]
\centering
\begin{tikzpicture}
\begin{axis}[xlabel={$t$},xmin=-3,xmax=21,
ylabel={$i_D$},ymin=0,ymax=5,
axis x line=center,
axis y line=left, enlargelimits=upper]
% draw sine functions
\addplot [dashed,thin,domain=-pi:6*pi,smooth]{-2*sin(deg(0.5*x))};
\addplot [dashed,thin,domain=-pi:6*pi,smooth]{ 2*sin(deg(0.5*x))};
% draw the rectified curves automatically via foreach skill
\foreach \i/\j/\k in {-1/0/1,1/2/3,3/4/5,5/6/7}{
\addplot [thick,domain=\i*pi:{\j*pi+\arch}, ] {2*e^(-0.05*(x-\i*pi)}; % exponentially decay curves, not a line
\addplot [thick,domain={\j*pi+\arch}:\k*pi, smooth]{ 2*sin(deg(0.5*x))};
\addplot [thick,domain={\j*pi+\arch}:\k*pi, smooth]{-2*sin(deg(0.5*x))};
}
\end{axis}
\end{tikzpicture}
\caption{Half-Wave Rectifier Waveform}
\label{halfcycle}
\end{figure}
\end{document}