I need help plotting a higher order transfer function using the package bodegraph. The transfer function is mind is the following:
Seing as bodegraph has no way of inputting a higher order than 2 transfer function, i tried decomposing the transfer function by partial fraction expansion and came out with the following residuals:
By having a series of 1st order functions i should be able to use the following bodegraph function to achieve the desired bodeplot:
After normalizing my functions i get the following residuals
By utilizing these i have the following input to BodeAmp function: \POAmp{K}{tau}
\BodeAmp[bode lines, red, name path=Gomagnitude]{-4:4}
{\POAmp{0.0000002562225476}{0.0003660322108}
+\POAmp{0.001246189024}{0.007621951220}
-\POAmp{0.07907822923}{0.06064281383}
+\POAmp{0.04071061644}{0.08561643836}
+ \POAmp{0.1185515519}{0.1783803068}
}
This however should produce the following output from matlab, but i dosent.
Im quite certain it either has to do with the pole in the right hand plane being input incorrectly to the POAmp function, (it didnt work setting both the gain and time constant negative to keep the input format), or the fact that i cant cascade the first order transfer functions like that using the residuals.
The full code is as following, which is a MWE that only plots the magnitude spectrum of the transfer function:
\documentclass[10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{decorations, positioning, intersections, calc}%
\usepackage{amsmath,amssymb}
\usepackage{bodegraph}
\begin{document}
% Define the layers to draw the diagram
\pgfdeclarelayer{background}
\pgfdeclarelayer{foreground}
\pgfsetlayers{background,main,foreground}
\begin{tikzpicture}[>=latex',
ref lines/.style={thin, black!60},
ref points/.style={circle, black, opacity=0.7, fill, minimum size= 3pt, inner sep=0},
every node/.style={font=\small},
bode lines/.style={very thick, blue},
Gclabel/.style={text=blue},
xscale=12/12,
gnuplot def/.style={samples=100,id=\arabic{idGnuplot},prefix=gnuplot/\jobname },
semilog lines/.style={thin, black!60},
semilog lines 2/.style={thin, black!20, dashed},
semilog half lines/.style={semilog lines 2, dashed },
Black lines/.style={very thick, blue},
Black grid/.style={ultra thin,brown},
Black abaque mag/.style={gray,ultra thin,dashed,smooth},
Black abaque phase/.style={gray,ultra thin,smooth},
Black label points/.style={font=\tiny},
Black label axes/.style={Black grid, font=\tiny},
Nyquist lines/.style={very thick, blue},
Nyquist grid/.style={ultra thin,brown},
Nyquist label axes/.style={Nyquist grid,font=\tiny},
Nyquist label points/.style={font=\tiny},
Temp lines/.style={very thick, blue},
Temp grid/.style={ultra thin,brown},
Temp label axes/.style={Temp grid, font=\tiny},
Temp label points/.style={font=\tiny},
Abaque grid/.style={ultra thin,brown!80},
Abaque lines/.style={thick, blue,smooth}
]
\begin{scope}[yscale=4/110]
\UnitedB
\semilog{-5}{5}{-150}{-50}
% Bode plot (magnitude) for the original system, 4/(s/(1+2s)).
% Asymptotic line
%\BodeAmp[ref lines, red!60]{-5:5}{\SOAmpAsymp{59.37351685}{1.538057009}{45.90206967}}
% Bode plot
\BodeAmp[bode lines, red, name path=Gomagnitude]{-4:4}{
+\POAmp{0.0000002562225476}{0.0003660322108}
+\POAmp{0.001246189024}{0.007621951220}
-\POAmp{0.07907822923}{0.06064281383}
+\POAmp{0.04071061644}{0.08561643836}
+ \POAmp{0.1185515519}{0.1783803068}
}
\end{scope}
\end{tikzpicture}
\end{document}