diff options
author | Karl Berry <karl@freefriends.org> | 2021-10-30 19:39:33 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2021-10-30 19:39:33 +0000 |
commit | b4b019077d0533f1cb161ba8f6090cc4c116d3ed (patch) | |
tree | b963111512f6516de2787fe43447c2d5742343ee /Master/texmf-dist/tex/latex/bodeplot | |
parent | 08b5f2098ebb0fe743ea196f74d047b024b9bf8c (diff) |
bodeplot (30oct21)
git-svn-id: svn://tug.org/texlive/trunk@60899 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/bodeplot')
-rw-r--r-- | Master/texmf-dist/tex/latex/bodeplot/bodeplot.sty | 681 |
1 files changed, 681 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/latex/bodeplot/bodeplot.sty b/Master/texmf-dist/tex/latex/bodeplot/bodeplot.sty new file mode 100644 index 00000000000..27bd7d37c0b --- /dev/null +++ b/Master/texmf-dist/tex/latex/bodeplot/bodeplot.sty @@ -0,0 +1,681 @@ +%% +%% This is file `bodeplot.sty', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% bodeplot.dtx (with options: `package') +%% This is a generated file. +%% Copyright (C) 2021 by Rushikesh Kamalapurkar +%% This file may be distributed and/or modified under the +%% conditions of the LaTeX Project Public License, either +%% version 1.3c of this license or (at your option) any later +%% version. The latest version of this license is in: +%% http://www.latex-project.org/lppl.txt +%% and version 1.3c or later is part of all distributions of +%% LaTeX version 2006/05/20 or later. + \NeedsTeXFormat{LaTeX2e}[2006/05/20] + \ProvidesPackage{bodeplot} + \RequirePackage{tikz} + \RequirePackage{pgfplots} + \pgfplotsset{compat=1.18,variable=t} + \usepgfplotslibrary{groupplots} + +\RequirePackage{ifluatex}% +\ifluatex + \RequirePackage{pdftexcmds}% + \let\pdfstrcmp\pdf@strcmp +\fi +\newif\if@pgfarg\@pgfargfalse +\DeclareOption{pgf}{% + \@pgfargtrue +} +\ProcessOptions\relax +\if@pgfarg + \newcommand{\n@pow}[2]{(#1)^(#2)}% + \newcommand{\n@mod}[2]{mod((#1),(#2))}% +\else + \newcommand{\n@pow}[2]{(#1)**(#2)}% + \newcommand{\n@mod}[2]{(#1)-(floor((#1)/(#2))*(#2))}% + \newcounter{idGnuplot}% + \setcounter{idGnuplot}{0}% + \tikzset{% + gnuplot def/.style={% + id=\arabic{idGnuplot}, + prefix=gnuplot/ + }% + } + \pgfplotsset{% + gnuplot degrees/.code={% + \ifnum\value{idGnuplot}=1 + \xdef\pgfplots@gnuplot@format{\pgfplots@gnuplot@format set angles degrees;}% + \fi + }% + } +\fi +\pgfplotsset{% + bodeStyle/.style = {% + label style={font=\footnotesize}, + tick label style={font=\footnotesize}, + grid=both, + major grid style={color=gray!80}, + minor grid style={color=gray!20}, + x label style={at={(ticklabel cs:0.5)},anchor=near ticklabel}, + y label style={at={(ticklabel cs:0.5)},anchor=near ticklabel}, + scale only axis, + samples=200, + width=5cm, + }% +} +\newcommand*{\MagK}[2]{(20*log10(abs(#1)))} +\newcommand*{\MagKAsymp}{\MagK} +\newcommand*{\MagKLin}{\MagK} +\newcommand*{\PhK}[2]{(#1<0?-180:0)} +\newcommand*{\PhKAsymp}{\PhK} +\newcommand*{\PhKLin}{\PhK} +\newcommand*{\MagDel}[2]{0} +\newcommand*{\PhDel}[2]{-#1*180*t/pi} +\newcommand*{\MagPole}[2] + {(-20*log10(sqrt(\n@pow{#1}{2} + \n@pow{t - (#2)}{2})))} +\newcommand*{\MagPoleLin}[2]{(t < sqrt(\n@pow{#1}{2} + \n@pow{#2}{2}) ? + -20*log10(sqrt(\n@pow{#1}{2} + \n@pow{#2}{2})) : + -20*log10(t) + )} +\newcommand*{\MagPoleAsymp}{\MagPoleLin} +\newcommand*{\PhPole}[2]{(#1 > 0 ? (#2 > 0 ? + (\n@mod{-atan2((t - (#2)),-(#1))+360}{360}) : + (-atan2((t - (#2)),-(#1)))) : + (-atan2((t - (#2)),-(#1))))} +\newcommand*{\PhPoleLin}[2]{% + (abs(#1)+abs(#2) == 0 ? -90 : + (t < (sqrt(\n@pow{#1}{2} + \n@pow{#2}{2}) / + (\n@pow{10}{sqrt(\n@pow{#1}{2}/(\n@pow{#1}{2} + \n@pow{#2}{2}))})) ? + (-atan2(-(#2),-(#1))) : + (t >= (sqrt(\n@pow{#1}{2} + \n@pow{#2}{2}) * + (\n@pow{10}{sqrt(\n@pow{#1}{2}/(\n@pow{#1}{2} + \n@pow{#2}{2}))})) ? + (#2>0?(#1>0?270:-90):-90) : + (-atan2(-(#2),-(#1)) + (log10(t/(sqrt(\n@pow{#1}{2} + \n@pow{#2}{2}) / + (\n@pow{10}{sqrt(\n@pow{#1}{2}/(\n@pow{#1}{2} + + \n@pow{#2}{2}))}))))*((#2>0?(#1>0?270:-90):-90) + atan2(-(#2),-(#1)))/ + (log10(\n@pow{10}{sqrt((4*\n@pow{#1}{2})/ + (\n@pow{#1}{2} + \n@pow{#2}{2}))}))))))} +\newcommand*{\PhPoleAsymp}[2]{(t < (sqrt(\n@pow{#1}{2} + \n@pow{#2}{2})) ? + (-atan2(-(#2),-(#1))) : + (#2>0?(#1>0?270:-90):-90))} +\newcommand*{\MagZero}{0-\MagPole} +\newcommand*{\MagZeroLin}{0-\MagPoleLin} +\newcommand*{\MagZeroAsymp}{0-\MagPoleAsymp} +\newcommand*{\PhZero}{0-\PhPole} +\newcommand*{\PhZeroLin}{0-\PhPoleLin} +\newcommand*{\PhZeroAsymp}{0-\PhPoleAsymp} +\newcommand*{\MagCSPoles}[2]{(-20*log10(sqrt(\n@pow{\n@pow{#2}{2} + - \n@pow{t}{2}}{2} + \n@pow{2*#1*#2*t}{2})))} +\newcommand*{\MagCSPolesLin}[2]{(t < #2 ? -40*log10(#2) : - 40*log10(t))} +\newcommand*{\MagCSPolesAsymp}{\MagCSPolesLin} +\newcommand*{\PhCSPoles}[2]{(-atan2((2*(#1)*(#2)*t),(\n@pow{#2}{2} + - \n@pow{t}{2})))} +\newcommand*{\PhCSPolesLin}[2]{(t < (#2 / (\n@pow{10}{abs(#1)})) ? + 0 : + (t >= (#2 * (\n@pow{10}{abs(#1)})) ? + (#1>0 ? -180 : 180) : + (#1>0 ? (-180*(log10(t*(\n@pow{10}{#1})/#2))/(2*#1)) : + (180*(log10(t*(\n@pow{10}{abs(#1)})/#2))/(2*abs(#1))))))} +\newcommand*{\PhCSPolesAsymp}[2]{(#1>0?(t<#2?0:-180):(t<#2?0:180))} +\newcommand*{\MagCSZeros}{0-\MagCSPoles} +\newcommand*{\MagCSZerosLin}{0-\MagCSPolesLin} +\newcommand*{\MagCSZerosAsymp}{0-\MagCSPolesAsymp} +\newcommand*{\PhCSZeros}{0-\PhCSPoles} +\newcommand*{\PhCSZerosLin}{0-\PhCSPolesLin} +\newcommand*{\PhCSZerosAsymp}{0-\PhCSPolesAsymp} +\newcommand*{\MagCSPolesPeak}[3][]{% + \draw[#1,->] (axis cs:{#3},{-40*log10(#3)}) -- + (axis cs:{#3},{-40*log10(#3)-20*log10(2*abs(#2))}) +} +\newcommand*{\MagCSZerosPeak}[3][]{% + \draw[#1,->] (axis cs:{#3},{40*log10(#3)}) -- + (axis cs:{#3},{40*log10(#3)+20*log10(2*abs(#2))}) +} +\newcommand*{\MagSOPoles}[2]{% + (-20*log10(sqrt(\n@pow{#2 - \n@pow{t}{2}}{2} + \n@pow{#1*t}{2})))} +\newcommand*{\MagSOPolesLin}[2]{% + (t < sqrt(abs(#2)) ? -20*log10(abs(#2)) : - 40*log10(t))} +\newcommand*{\MagSOPolesAsymp}{\MagSOPolesLin} +\newcommand*{\PhSOPoles}[2]{(-atan2((#1)*t,((#2) - \n@pow{t}{2})))} +\newcommand*{\PhSOPolesLin}[2]{(#2>0 ? + \PhCSPolesLin{(#1/(2*sqrt(#2)))}{(sqrt(#2))} : + (#1>0 ? -180 : 180))} +\newcommand*{\PhSOPolesAsymp}[2]{(#2>0 ? + \PhCSPolesAsymp{(#1/(2*sqrt(#2)))}{(sqrt(#2))} : + (#1>0 ? -180 : 180))} +\newcommand*{\MagSOZeros}{0-\MagSOPoles} +\newcommand*{\MagSOZerosLin}{0-\MagSOPolesLin} +\newcommand*{\MagSOZerosAsymp}{0-\MagSOPolesAsymp} +\newcommand*{\PhSOZeros}{0-\PhSOPoles} +\newcommand*{\PhSOZerosLin}{0-\PhSOPolesLin} +\newcommand*{\PhSOZerosAsymp}{0-\PhSOPolesAsymp} +\newcommand*{\MagSOPolesPeak}[3][]{% + \draw[#1,->] (axis cs:{sqrt(abs(#3))},{-20*log10(abs(#3))}) -- + (axis cs:{sqrt(abs(#3))},{-20*log10(abs(#3)) - + 20*log10(abs(#2/sqrt(abs(#3))))}); +} +\newcommand*{\MagSOZerosPeak}[3][]{% + \draw[#1,->] (axis cs:{sqrt(abs(#3))},{20*log10(abs(#3))}) -- + (axis cs:{sqrt(abs(#3))},{20*log10(abs(#3)) + + 20*log10(abs(#2/sqrt(abs(#3))))}); +} +\newcommand{\BodeZPK}[4][]{% + \parse@opt{#1}% + \gdef\func@mag{}% + \gdef\func@ph{}% + \build@ZPK@plot{\func@mag}{\func@ph}{\opt@approx}{#2}% + \edef\temp@cmd{\noexpand\begin{tikzpicture}\noexpand\begin{groupplot}[% + bodeStyle, + xmin={#3}, + xmax={#4}, + domain=#3:#4, + height=2.5cm, + xmode=log, + group style = {group size = 1 by 2,vertical sep=0.25cm,}, + \opt@group,]} + \temp@cmd + \if@pgfarg + \expandafter\nextgroupplot\expandafter[ytick distance=20, + ylabel={Gain (dB)},xmajorticks=false,\optmag@axes] + \edef\temp@cmd{\noexpand\addplot[red,thick,\optmag@plot]}% + \temp@cmd {\func@mag}; + \expandafter\nextgroupplot\expandafter[ytick distance=45, + ylabel={Phase ($^{\circ}$)},xlabel={Frequency (rad/s)},\optph@axes] + \edef\temp@cmd{\noexpand\addplot[red,thick,\optph@plot]}% + \temp@cmd {\func@ph}; + \else + \stepcounter{idGnuplot} + \expandafter\nextgroupplot\expandafter[ytick distance=20, + ylabel={Gain (dB)},xmajorticks=false,\optmag@axes] + \edef\temp@cmd{\noexpand\addplot[red,thick,\optmag@plot]}% + \temp@cmd gnuplot[gnuplot degrees,gnuplot def] {\func@mag}; + \stepcounter{idGnuplot} + \expandafter\nextgroupplot\expandafter[ytick distance=45, + ylabel={Phase ($^{\circ}$)},xlabel={Frequency (rad/s)},\optph@axes] + \edef\temp@cmd{\noexpand\addplot[red,thick,\optph@plot]}% + \temp@cmd gnuplot[gnuplot degrees,gnuplot def] {\func@ph}; + \fi + \end{groupplot}\end{tikzpicture}} +\newcommand{\BodeTF}[4][]{% + \parse@opt{#1}% + \gdef\func@mag{}% + \gdef\func@ph{}% + \build@TF@plot{\func@mag}{\func@ph}{#2}% + \edef\temp@cmd{\noexpand\begin{tikzpicture}\noexpand\begin{groupplot}[% + bodeStyle, + xmin={#3}, + xmax={#4}, + domain=#3:#4, + height=2.5cm, + xmode=log, + group style = {group size = 1 by 2,vertical sep=0.25cm,}, + \opt@group,]} + \temp@cmd + \if@pgfarg + \expandafter\nextgroupplot\expandafter[ytick distance=20, + ylabel={Gain (dB)},xmajorticks=false,\optmag@axes] + \edef\temp@cmd{\noexpand\addplot[red,thick,\optmag@plot]}% + \temp@cmd {\func@mag}; + \expandafter\nextgroupplot\expandafter[ytick distance=45, + ylabel={Phase ($^{\circ}$)},xlabel={Frequency (rad/s)},\optph@axes] + \edef\temp@cmd{\noexpand\addplot[red,thick,\optph@plot]}% + \temp@cmd {\func@ph}; + \else + \stepcounter{idGnuplot}% + \expandafter\nextgroupplot\expandafter[ytick distance=20, + ylabel={Gain (dB)},xmajorticks=false,\optmag@axes] + \edef\temp@cmd{\noexpand\addplot[red,thick,\optmag@plot]}% + \temp@cmd gnuplot[gnuplot degrees,gnuplot def] {\func@mag}; + \stepcounter{idGnuplot}% + \expandafter\nextgroupplot\expandafter[ytick distance=45, + ylabel={Phase ($^{\circ}$)},xlabel={Frequency (rad/s)},\optph@axes] + \edef\temp@cmd{\noexpand\addplot[red,thick,\optph@plot]}% + \temp@cmd gnuplot[gnuplot degrees,gnuplot def] {\func@ph}; + \fi + \end{groupplot}\end{tikzpicture}} +\newcommand{\addBodeZPKPlots}[3][{}]{% + \foreach \approx/\opt in {#1} {% + \gdef\plot@macro{}% + \gdef\temp@macro{}% + \ifnum\pdfstrcmp{#2}{phase}=0 + \build@ZPK@plot{\temp@macro}{\plot@macro}{\approx}{#3}% + \else + \build@ZPK@plot{\plot@macro}{\temp@macro}{\approx}{#3}% + \fi + \if@pgfarg + \edef\temp@cmd{\noexpand\addplot[red,thick,\opt]}% + \temp@cmd {\plot@macro}; + \else + \stepcounter{idGnuplot}% + \edef\temp@cmd{\noexpand\addplot[red,thick,\opt]} + \temp@cmd gnuplot[gnuplot degrees,gnuplot def] {\plot@macro}; + \fi + }% +} +\newcommand{\addBodeTFPlot}[3][red,thick]{% + \gdef\plot@macro{}% + \gdef\temp@macro{}% + \ifnum\pdfstrcmp{#2}{phase}=0 + \build@TF@plot{\temp@macro}{\plot@macro}{#3}% + \else + \build@TF@plot{\plot@macro}{\temp@macro}{#3}% + \fi + \if@pgfarg + \addplot[#1]{\plot@macro}; + \else + \stepcounter{idGnuplot}% + \addplot[#1] gnuplot[gnuplot degrees, gnuplot def] {\plot@macro}; + \fi +} +\newcommand{\addBodeComponentPlot}[2][red,thick]{% + \if@pgfarg + \addplot[#1]{#2}; + \else + \stepcounter{idGnuplot}% + \addplot[#1] gnuplot[gnuplot degrees,gnuplot def] {#2}; + \fi +} +\newenvironment{BodePlot}[3][]{% + \begin{tikzpicture} + \begin{semilogxaxis}[% + bodeStyle, + xmin={#2}, + xmax={#3}, + domain=#2:#3, + height=2.5cm, + xlabel={Frequency (rad/s)}, + #1] +}{ + \end{semilogxaxis} + \end{tikzpicture} +} +\newcommand*{\add@feature}[3]{% + \ifcat$\detokenize\expandafter{#1}$% + \xdef#1{\unexpanded\expandafter{#1 0+#2}}% + \else + \xdef#1{\unexpanded\expandafter{#1+#2}}% + \fi + \foreach \y [count=\n] in #3 {% + \xdef#1{\unexpanded\expandafter{#1}{\y}}% + \xdef\Last@LoopValue{\n}% + }% + \ifnum\Last@LoopValue=1% + \xdef#1{\unexpanded\expandafter{#1}{0}}% + \fi +} +\newcommand{\build@ZPK@plot}[4]{% + \foreach \feature/\values in {#4} {% + \ifnum\pdfstrcmp{\feature}{z}=0 + \foreach \z in \values {% + \ifnum\pdfstrcmp{#3}{linear}=0 + \add@feature{#2}{\PhZeroLin}{\z}% + \add@feature{#1}{\MagZeroLin}{\z}% + \else + \ifnum\pdfstrcmp{#3}{asymptotic}=0 + \add@feature{#2}{\PhZeroAsymp}{\z}% + \add@feature{#1}{\MagZeroAsymp}{\z}% + \else + \add@feature{#2}{\PhZero}{\z}% + \add@feature{#1}{\MagZero}{\z}% + \fi + \fi + }% + \fi + \ifnum\pdfstrcmp{\feature}{p}=0 + \foreach \p in \values {% + \ifnum\pdfstrcmp{#3}{linear}=0 + \add@feature{#2}{\PhPoleLin}{\p}% + \add@feature{#1}{\MagPoleLin}{\p}% + \else + \ifnum\pdfstrcmp{#3}{asymptotic}=0 + \add@feature{#2}{\PhPoleAsymp}{\p}% + \add@feature{#1}{\MagPoleAsymp}{\p}% + \else + \add@feature{#2}{\PhPole}{\p}% + \add@feature{#1}{\MagPole}{\p}% + \fi + \fi + }% + \fi + \ifnum\pdfstrcmp{\feature}{k}=0 + \ifnum\pdfstrcmp{#3}{linear}=0 + \add@feature{#2}{\PhKLin}{\values}% + \add@feature{#1}{\MagKLin}{\values}% + \else + \ifnum\pdfstrcmp{#3}{asymptotic}=0 + \add@feature{#2}{\PhKAsymp}{\values}% + \add@feature{#1}{\MagKAsymp}{\values}% + \else + \add@feature{#2}{\PhK}{\values}% + \add@feature{#1}{\MagK}{\values}% + \fi + \fi + \fi + \ifnum\pdfstrcmp{\feature}{d}=0 + \ifnum\pdfstrcmp{#3}{linear}=0 + \PackageError {bodeplot} {Linear approximation for pure delays is not + supported.} {Plot the true Bode plot using 'true' instead of 'linear'.} + \else + \ifnum\pdfstrcmp{#3}{asymptotic}=0 + \PackageError {bodeplot} {Asymptotic approximation for pure delays is not + supported.} {Plot the true Bode plot using 'true' instead of 'asymptotic'.} + \else + \ifdim\values pt < 0pt + \PackageError {bodeplot} {Delay needs to be a positive number.} + \fi + \add@feature{#2}{\PhDel}{\values}% + \add@feature{#1}{\MagDel}{\values}% + \fi + \fi + \fi + }% +} +\newcommand{\build@TF@plot}[3]{% + \gdef\num@real{0}% + \gdef\num@im{0}% + \gdef\den@real{0}% + \gdef\den@im{0}% + \gdef\loop@delay{0}% + \foreach \feature/\values in {#3} {% + \ifnum\pdfstrcmp{\feature}{num}=0 + \foreach \numcoeff [count=\numpow] in \values {% + \xdef\num@degree{\numpow}% + }% + \foreach \numcoeff [count=\numpow] in \values {% + \pgfmathtruncatemacro{\currentdegree}{\num@degree-\numpow}% + \ifnum\currentdegree = 0 + \xdef\num@real{\num@real+\numcoeff}% + \else + \ifodd\currentdegree + \xdef\num@im{\num@im+(\numcoeff*(\n@pow{-1}{(\currentdegree-1)/2})*% + (\n@pow{t}{\currentdegree}))}% + \else + \xdef\num@real{\num@real+(\numcoeff*(\n@pow{-1}{(\currentdegree)/2})*% + (\n@pow{t}{\currentdegree}))}% + \fi + \fi + }% + \fi + \ifnum\pdfstrcmp{\feature}{den}=0 + \foreach \dencoeff [count=\denpow] in \values {% + \xdef\den@degree{\denpow}% + }% + \foreach \dencoeff [count=\denpow] in \values {% + \pgfmathtruncatemacro{\currentdegree}{\den@degree-\denpow}% + \ifnum\currentdegree = 0 + \xdef\den@real{\den@real+\dencoeff}% + \else + \ifodd\currentdegree + \xdef\den@im{\den@im+(\dencoeff*(\n@pow{-1}{(\currentdegree-1)/2})*% + (\n@pow{t}{\currentdegree}))}% + \else + \xdef\den@real{\den@real+(\dencoeff*(\n@pow{-1}{(\currentdegree)/2})*% + (\n@pow{t}{\currentdegree}))}% + \fi + \fi + }% + \fi + \ifnum\pdfstrcmp{\feature}{d}=0 + \xdef\loop@delay{\values}% + \fi + }% + \xdef#2{(\n@mod{atan2((\num@im),(\num@real))-atan2((\den@im),% + (\den@real))+360}{360}-\loop@delay*180*t/pi)}% + \xdef#1{(20*log10(sqrt((\n@pow{\num@real}{2})+(\n@pow{\num@im}{2})))-% + 20*log10(sqrt((\n@pow{\den@real}{2})+(\n@pow{\den@im}{2}))))}% +} +\newcommand{\parse@opt}[1]{% + \gdef\optmag@axes{}% + \gdef\optph@axes{}% + \gdef\optph@plot{}% + \gdef\optmag@plot{}% + \gdef\opt@group{}% + \gdef\opt@approx{}% + \foreach \obj/\typ/\opt in {#1} {% + \ifnum\pdfstrcmp{\obj}{plot}=0 + \ifnum\pdfstrcmp{\typ}{mag}=0 + \xdef\optmag@plot{\optmag@plot,\opt}% + \else + \ifnum\pdfstrcmp{\typ}{ph}=0 + \xdef\optph@plot{\optph@plot,\opt}% + \else + \xdef\optmag@plot{\optmag@plot,\opt}% + \xdef\optph@plot{\optph@plot,\opt}% + \fi + \fi + \else + \ifnum\pdfstrcmp{\obj}{axes}=0 + \ifnum\pdfstrcmp{\typ}{mag}=0 + \xdef\optmag@axes{\optmag@axes,\opt}% + \else + \ifnum\pdfstrcmp{\typ}{ph}=0 + \xdef\optph@axes{\optph@axes,\opt}% + \else + \xdef\optmag@axes{\optmag@axes,\opt}% + \xdef\optph@axes{\optph@axes,\opt}% + \fi + \fi + \else + \ifnum\pdfstrcmp{\obj}{group}=0 + \xdef\opt@group{\opt@group,\opt}% + \else + \ifnum\pdfstrcmp{\obj}{approx}=0 + \xdef\opt@approx{\typ}% + \else + \xdef\optmag@plot{\optmag@plot,\obj}% + \xdef\optph@plot{\optph@plot,\obj}% + \fi + \fi + \fi + \fi + }% +} +\newcommand{\NyquistZPK}[4][]{% + \parse@N@opt{#1}% + \gdef\func@mag{}% + \gdef\func@ph{}% + \build@ZPK@plot{\func@mag}{\func@ph}{}{#2}% + \edef\temp@cmd{\noexpand\begin{tikzpicture}\noexpand\begin{axis}[% + bodeStyle, + domain=#3:#4, + height=5cm, + xlabel={$\Re$}, + ylabel={$\Im$}, + samples=500, + \opt@axes,]}% + \temp@cmd + \addplot [only marks,mark=+,thick,red] (-1 , 0); + \edef\temp@cmd{\noexpand\addplot[thick,\unexpanded\expandafter{\opt@plot}]}% + \if@pgfarg + \temp@cmd ( {\n@pow{10}{((\func@mag)/20)}*cos(\func@ph)}, + {\n@pow{10}{((\func@mag)/20)}*sin(\func@ph)} ); + \else + \stepcounter{idGnuplot}% + \temp@cmd gnuplot[parametric,gnuplot degrees,gnuplot def] {% + \n@pow{10}{((\func@mag)/20)}*cos(\func@ph), + \n@pow{10}{((\func@mag)/20)}*sin(\func@ph)}; + \fi + \end{axis} + \end{tikzpicture} +} +\newcommand{\NyquistTF}[4][]{% + \parse@N@opt{#1}% + \gdef\func@mag{}% + \gdef\func@ph{}% + \build@TF@plot{\func@mag}{\func@ph}{#2}% + \edef\temp@cmd{\noexpand\begin{tikzpicture}\noexpand\begin{axis}[% + bodeStyle, + domain=#3:#4, + height=5cm, + xlabel={$\Re$}, + ylabel={$\Im$}, + samples=500, + \opt@axes,]} + \temp@cmd + \addplot [only marks,mark=+,thick,red] (-1 , 0); + \edef\temp@cmd{\noexpand\addplot[thick,\unexpanded\expandafter{\opt@plot}]}% + \if@pgfarg + \temp@cmd ( {\n@pow{10}{((\func@mag)/20)}*cos(\func@ph)}, + {\n@pow{10}{((\func@mag)/20)}*sin(\func@ph)} ); + \else + \stepcounter{idGnuplot}% + \temp@cmd gnuplot[parametric,gnuplot degrees,gnuplot def]{% + \n@pow{10}{((\func@mag)/20)}*cos(\func@ph), + \n@pow{10}{((\func@mag)/20)}*sin(\func@ph)}; + \fi + \end{axis} + \end{tikzpicture} +} +\newcommand{\addNyquistZPKPlot}[2][]{% + \gdef\func@mag{}% + \gdef\func@ph{}% + \build@ZPK@plot{\func@mag}{\func@ph}{}{#2}% + \if@pgfarg + \addplot [#1] ( {\n@pow{10}{((\func@mag)/20)}*cos(\func@ph)}, + {\n@pow{10}{((\func@mag)/20)}*sin(\func@ph)} ); + \else + \stepcounter{idGnuplot}% + \addplot [#1] gnuplot[parametric,gnuplot degrees,gnuplot def]{% + \n@pow{10}{((\func@mag)/20)}*cos(\func@ph), + \n@pow{10}{((\func@mag)/20)}*sin(\func@ph)}; + \fi +} +\newcommand{\addNyquistTFPlot}[2][]{% + \gdef\func@mag{}% + \gdef\func@ph{}% + \build@TF@plot{\func@mag}{\func@ph}{#2}% + \if@pgfarg + \addplot [#1] ( {\n@pow{10}{((\func@mag)/20)}*cos(\func@ph)}, + {\n@pow{10}{((\func@mag)/20)}*sin(\func@ph)} ); + \else + \stepcounter{idGnuplot}% + \addplot [#1] gnuplot[parametric,gnuplot degrees,gnuplot def]{% + \n@pow{10}{((\func@mag)/20)}*cos(\func@ph), + \n@pow{10}{((\func@mag)/20)}*sin(\func@ph)}; + \fi +} +\newenvironment{NyquistPlot}[3][]{% + \begin{tikzpicture} + \begin{axis}[% + bodeStyle, + height=5cm, + domain=#2:#3, + xlabel={$\Re$}, + ylabel={$\Im$}, + #1] + \addplot [only marks,mark=+,thick,red] (-1 , 0); +}{% + \end{axis} + \end{tikzpicture} +} +\newcommand{\parse@N@opt}[1]{% + \gdef\opt@axes{}% + \gdef\opt@plot{}% + \foreach \obj/\opt in {#1} {% + \ifnum\pdfstrcmp{\obj}{axes}=0 + \xdef\opt@axes{\unexpanded\expandafter{\opt}}% + \else + \ifnum\pdfstrcmp{\obj}{plot}=0 + \xdef\opt@plot{\unexpanded\expandafter{\opt}}% + \else + \xdef\opt@plot{\unexpanded\expandafter{\obj}}% + \fi + \fi + }% +} +\newcommand{\NicholsZPK}[4][]{% + \parse@N@opt{#1}% + \gdef\func@mag{}% + \gdef\func@ph{}% + \build@ZPK@plot{\func@mag}{\func@ph}{}{#2}% + \edef\temp@cmd{\noexpand\begin{tikzpicture}\noexpand\begin{axis}[% + bodeStyle, + domain=#3:#4, + height=5cm, + xlabel={Phase (degrees)}, + ylabel={Gain (dB)}, + samples=500, + \opt@axes]} + \temp@cmd + \edef\temp@cmd{\noexpand\addplot[red,thick,\opt@plot]}% + \if@pgfarg + \temp@cmd ( {\func@ph} , {\func@mag} ); + \else + \stepcounter{idGnuplot}% + \temp@cmd gnuplot[parametric, gnuplot degrees, gnuplot def] + { \func@ph , \func@mag }; + \fi + \end{axis} + \end{tikzpicture} +} +\newcommand{\NicholsTF}[4][]{% + \parse@N@opt{#1}% + \gdef\func@mag{}% + \gdef\func@ph{}% + \build@TF@plot{\func@mag}{\func@ph}{#2}% + \edef\temp@cmd{\noexpand\begin{tikzpicture}\noexpand\begin{axis}[% + bodeStyle, + domain=#3:#4, + height=5cm, + xlabel={Phase (degrees)}, + ylabel={Gain (dB)}, + samples=500, + \opt@axes]} + \temp@cmd + \edef\temp@cmd{\noexpand\addplot[red,thick,\opt@plot]}% + \if@pgfarg + \temp@cmd ( {\func@ph} , {\func@mag} ); + \else + \stepcounter{idGnuplot}% + \temp@cmd gnuplot[parametric, gnuplot degrees, gnuplot def] + { \func@ph , \func@mag }; + \fi + \end{axis} + \end{tikzpicture} +} +\newenvironment{NicholsChart}[3][]{% + \begin{tikzpicture} + \begin{axis}[% + bodeStyle, + domain=#2:#3, + height=5cm, + ytick distance=20, + xtick distance=15, + xlabel={Phase (degrees)}, + ylabel={Gain (dB)}, + #1] +}{ + \end{axis} + \end{tikzpicture} +} +\newcommand{\addNicholsZPKChart}[2][]{% + \gdef\func@mag{}% + \gdef\func@ph{}% + \build@ZPK@plot{\func@mag}{\func@ph}{}{#2}% + \if@pgfarg + \addplot [#1] ( {\func@ph} , {\func@mag} ); + \else + \stepcounter{idGnuplot}% + \addplot [#1] gnuplot[parametric,gnuplot degrees,gnuplot def] + {\func@ph , \func@mag}; + \fi +} +\newcommand{\addNicholsTFChart}[2][]{% + \gdef\func@mag{}% + \gdef\func@ph{}% + \build@TF@plot{\func@mag}{\func@ph}{#2}% + \if@pgfarg + \addplot [#1] ( {\func@ph} , {\func@mag} ); + \else + \stepcounter{idGnuplot}% + \addplot [#1] gnuplot[gnuplot degrees,gnuplot def] + {\func@ph , \func@mag}; + \fi +} +\endinput +%% +%% End of file `bodeplot.sty'. |