bodeplot¶
基本说明¶
Generate Bode, Nyquist, and Nichols plots for transfer functions in the canonical (TF) form
and the zero-pole-gain (ZPK) form
In the equations above, \(b_m,\cdots,b_0\) and \(a_n,\cdots,a_0\) are real coefficients, \(T\geq 0\) is the loop delay, \(z_1,\cdots,z_m\) and \(p_1,\cdots,p_n\) are complex zeros and poles of the transfer function, respectively, and \(K\in \Re\) is the loop gain. For transfer functions in the ZPK format in (\ref{eq:ZPK}) with zero delay, this package also supports linear and asymptotic approximation of Bode plots.
\textbf{Limitation:} in TF form, the phase angles are always between 0 and 360\(^\circ\), As such, the Bode phase plots and the Nyquist and Nichols plots will have phase wrapping discontinuities. I do not know how this can be rectified, pull requests are welcome!
使用方法¶
\BodeZPK¶
\BodeZPK [⟨obj1/typ1/{⟨opt1 ⟩},obj2/typ2/{⟨opt2 ⟩},...⟩]
{⟨z/{⟨zeros⟩},p/{⟨poles⟩},k/{⟨gain⟩},d/{⟨delay⟩}⟩}
{⟨min-freq⟩}{⟨max-freq⟩}
3个强制性参数¶
{⟨z/{⟨zeros⟩},p/{⟨poles⟩},k/{⟨gain⟩},d/{⟨delay⟩}⟩}一组元组的列表,由零、极点、增益、和传输延迟组成的传递函数- 频率最小值
{⟨min-freq⟩} - 频率最大值
{⟨max-freq⟩}
可选参数¶
-
数组
obj/typ/{opt} -
plot/typ/{opt}通过{opt}修改**plot**参数(\addplot宏),typ为mag时修订幅频图,typ为ph时修订相频图 axes/typ/{opt}通过{opt}修改**坐标轴**参数(\nextgroupplot宏),typ为mag时修订幅频图,typ为ph时修订相频图-
commands/typ/{opt}增加TikZ命令(包括本包中的参数曲线函数,如\addBodeZPKPlots、\addBodeTFPlot、\addBodeComponentPlot)。typ为mag时修订幅频图,typ为ph时修订相频图。传递给opt的命令必须是合法的TikZ命令(利用分号分隔)。 -
数组
obj/{opt} -
plot/{opt}向幅频与相频图均新增plot参数opt(\addplot宏) axes/{opt}向幅频与相频图均新增**坐标轴**参数opt(\nextgroupplot宏)group/{opt}向groupplot环境中新增参数opttikz/{opt}向tikzpicture环境中新增参数optapprox/linear绘制线性渐近线-
approx/asymptotic绘制渐近线 -
数组
{opt}向幅频与相频图均新增plot参数opt(\addplot宏)
{opt}选项可以为pgfplots宏包中支持的所有key=value项。
Example
\begin{equation} G(s) = 10\frac{s(s+0.1+0.5\mathrm{i})(s+0.1-0.5\mathrm{i})}{(s+0.5+10\mathrm{i})(s+0.5-10\mathrm{i})},\label{eq:ZPKExample} \end{equation} 在频率\([0.01,100]\)上的Bode图可用下列命令生成
如果延迟没有指定则假定为0,若增益没有指定则假定为1。默认情况下,\BodeZPK的坐标轴为5cm宽2.5cm高。(高度与宽度可以通过pgf的选项进行更改)
带有线性渐近线的Bode图的绘制命令如下:
\BodeZPK[plot/mag/{red,thick},
plot/ph/{blue,thick},
axes/mag/{ytick distance=40,xmajorticks=true,xlabel={Frequency (rad/s)}},
axes/ph/{ytick distance=90},
group/{group style={group size=2 by 1,horizontal sep=2cm, width=4cm,height=2cm}},
approx/linear]
{z/{0,{-0.1,-0.5},{-0.1,0.5}},p/{{-0.5,-10},{-0.5,10}},k/10}
{0.01}{100}
\BodeTF¶
利用TF形式传递函数绘制Bode图
\BodeTF[{obj1/typ1/{opt1},obj2/typ2/{opt2},...}]
{num/{coeffs},den/{coeffs},d/{delay}}
{min-freq}{max-freq}
3个强制性参数¶
{num/{coeffs},den/{coeffs},d/{delay}}一组元组的列表,由传递函数的分子与分母组成- 频率最小值
{⟨min-freq⟩} - 频率最大值
{⟨max-freq⟩}
可选参数¶
可选参数与\BodeZPK一致,除了**线性渐近线选项**,不支持\approx系列选项
Example
同样的传递函数 \begin{equation} G(s) = 10\frac{s(s+0.1+0.5\mathrm{i})(s+0.1-0.5\mathrm{i})}{(s+0.5+10\mathrm{i})(s+0.5-10\mathrm{i})}, \end{equation}
频率区间为\([0.01,100]\),相应的代码为
\BodeTF[commands/mag/{\node at (axis cs: 2.1,0)
[circle,fill,inner sep=0.05cm,label=below:{$\omega_{gc}$}]{};}]
{num/{10,2,2.6,0},den/{1,1,100.25},d/0.01}
{0.01}{100}
Warning
分子项中增加了一个\(0\)以表示分子中不包含常数项
\commands项中的TikZ命令以分号结束

BodePlot¶
\begin{BodePlot}[{obj1/{opt1},obj2/{opt2},...}
{min-frequency}{max-frequency}
\addBode...
\end{BodePlot}
BodePlot绘图环境与宏命令\addBodeZPKPlots、\addBodeTFPlot,、\addBodeComponentPlot配合使用。
可选参数¶
可选参数由一系列数组obj/{opt}或{opt}构成。
- 数组
obj/{opt}tikz/{opt}修改应用于tikzpicture环境的{opt}选项axes/{opt}修改应用于semilogaxis环境的{opt}选项commands/{opt}
- 数组
{opt}直接修改应用于semilogaxis环境的{opt}选项
Note
频率范围用于确定semilogaxis环境中x轴的范围。具体的应用案例见\addBodeZPKPlots、\addBodeTFPlot,、\addBodeComponentPlot的使用说明。
\addBodeZPKPlots¶
\addBodeZPKPlots [approx1/{opt1},approx2/{opt2},...]
{plot-type}
{z/{zeros},p/{poles},k/{gain},d/{delay}}
\addplot宏命令。
可选参数项approx/{opt}的可选内容为true/{opt}、linear/{opt}、asymptotic/{opt}。如果可选参数项approx/{opt}项为空,则默认值为true/{opt}。
\addBodeZPKPlots宏命令可以用在semilogaxis环境中