2

How can be plotted a transfer function in a bodeplot. I just installed the bodegraph package, and have the "paper" already done but I dont understand the format to input the transfer function, I dont know what is missing.

The MWE

    \documentclass{article}

\usepackage{tikz}
\usepackage{bodegraph}

\begin{document}

\begin{tikzpicture}[
    gnuplot def/.append style={prefix={}}, % Fixed the issue (prefix was 'gnuplot/\jobname/' before)
]
\begin{scope}[xscale=10/3,yscale=10/110]
\UnitedB
\tikzset{
semilog lines/.style={thin, blue},
semilog lines 2/.style={semilog lines,
red!50 },
semilog half lines/.style={semilog lines 2,
dotted },
semilog label x/.style={semilog lines,
below,font=\tiny},
semilog label y/.style={semilog lines,
right,font=\tiny}
}
\semilog{0}{6}{0}{106}
\BodeGraph{0:4}{20*log10(abs(1/sqrt(1+(1*100000**t)**2)))}
\end{scope}
\end{tikzpicture}

\end{document}

enter image description here

Update
Looking the output it says

Package pgf Warning: Plot data file `1.table' not found. on input line 15.

I don't want to edit the .sty file to update, so how can be adjusted the code? I understand the bodeplot package uses gnuplot, so it has been checked and confirmed to be installed on the system.

New Update
I have reinstalled the bodegraph package, but Im still mismatching the function.The idea is to make it to look more or less to

enter image description here I dont know what function is it.

2
  • 3
    The latest version of bodegraph is 11 years old. I do not know Bode plots, but it looks straight forward - can PGFPlots not be used? Sep 16 at 7:48
  • 3
    Basically, a Bode plot is a log-log plot with dB (10 log(y)) verses frequency. The tricky bit is that it takes y as as input but shows dB on the y axis, not y. Sep 16 at 15:27
4

I do not know what a Bode plot is, but her is a replica of your graph in PGFPlots.

\documentclass[tikz, border=1 cm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\begin{document}
\begin{tikzpicture}
   \begin{axis}[
   xmode=log, 
   xmin=1, xmax=10000000,
   ymin=0, ymax=110,
   axis x line=bottom,axis y line=left,
   xlabel=$f(Hz)$,
   ylabel=$A_{ol}(dB)$,
   every axis x label/.style={
     at={(ticklabel* cs:1.05)},
     anchor=west},
   every axis y label/.style={
     at={(ticklabel* cs:1.05)},
     anchor=south,},
   tick align=outside,
   xtick={1,10,100,1000,10000,100000,1000000},
   xticklabels={1,10,100,1k,10k,100k,1M},
   ytick={0,25,50,75,100},
   extra y ticks={106}, extra y tick labels={106},
   extra y tick style={y tick  style={draw=none}},
   axis on top=true,
   ]
  \fill[lightgray] (1,0) rectangle (10,106);
  \draw[dashed] (10,0) -- (10,106);
  \addplot[blue, thick] coordinates {(1,106) (10,106) (2000000,0)};
  \end{axis}
\end{tikzpicture}
\end{document}

Semilog plot with single blue line and filled gray area

4

I digged out a Bode plot I used in one of my exercises. This is plotted manually, and already in dB in the y axis, with the real (red) and asymptotic (draw by hand, in this case, but there are other strategies). It has big fonts because it's normally in an inset on the page, but you can change them easily.

I hope it can help as a starting point.

\documentclass[border=10pt]{standalone}
\usepackage{pgfplots}\pgfplotsset{compat=1.18}
\usepackage{siunitx}
\usetikzlibrary{arrows.meta,}
\begin{document}
\begin{tikzpicture}[baseline=(g.north),]% name and baseline are for positioning the graph
        \begin{axis}[name=g,
                height=5cm, width=0.5\linewidth,
                xmin=1, xmax=1000,xmode=log,
                ymin=0, ymax=60,
                domain=1:1000,
                xlabel = {$f$~(Hz)},
                ylabel = {$|A_v|$~(dB)},
                legend style = {nodes={right, font=\scriptsize}, at={(0.05,0.6)}, anchor=west},
                clip mode = individual,
                grid=both,
                ]
                \addplot[thick, blue, domain=1:4] {14};
                \addplot[thick, blue, domain=318:1000] {52};
                \draw [thick, blue] (4,14) node[right=8pt]{\SI{14}{dB}} -- (318,52) node[left=8pt]{\SI{52}{dB}};
                \draw [thick, blue, dashed] (318,52) -- (318,0) node[above left]{\SI{318}{Hz}};
                \draw [thick, blue, dashed] (4,14) -- (4,0) node[above left]{\SI{4}{Hz}};
                % notice that 20*log10(sqrt...) is the same as 10*log(...)
                \addplot[red] {14 % static gain
                        +10*log10(1+x*x/(4*4)) % zero
                        -10*log10(1+x*x/(318*318)) % pole
                    };
            \end{axis}
    \end{tikzpicture}
\end{document}

enter image description here

1
  • 1
    Its a great example and not so simple, ita very valuable, and taking into account its made at hand. Thanks so much.
    – avelardo
    Oct 3 at 16:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.