PGF 圖中的電壓圖

PGF 圖中的電壓圖

在 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}

相關內容