Changes

Jump to navigation Jump to search

Control package

1,580 bytes added, 06:03, 29 September 2015
=== PT1 / Low-pass filter step response ===
 
<!-- {{SyntaxHighlight| -->
{{Code|Creating a transfer function and plotting its response|<syntaxhighlight lang="octave" style="font-size:14px">
T1 = 0.4; # time constant
P = tf([1], [T1 1]) ; # create transfer function model
step(P, 2) # plot step response
[[File:Pt1.png|600px]]
Try also ==== Bode Diagram for TikZ/PGFplots ==== We use the same system as before but we draw now with the <code style="font-size:14px; border:solid lightgray 1px; padding: 2px">bode(P)</code> a bode diagram.The output is then written to a .csv file. <!-- {{SyntaxHighlight| -->{{Code|Creating a transfer function and plotting its response|<syntaxhighlight lang="octave" style="font-size:14px"> T1 = 0.4; # time constant P = tf([1], [T1 1]);  [mag, pha, w] = bode(P);  csvwrite("dat/bode_p.csv", [w', 20*log10(mag), pha]);</syntaxhighlight>}} We can then invoke LaTeX with the following .tex file <!-- {{SyntaxHighlight| -->{{Code|Creating a transfer function and plotting its response|<syntaxhighlight lang="latex" style="font-size:14px">\documentclass[tikz]{standalone}\usepackage{pgfplotstable}\usepackage{siunitx}\usetikzlibrary{pgfplots.groupplots} \begin{document}\pgfplotstableread[col sep=comma]{\detokenize{/path/to/csv/file/dat/bode_p.csv}}\datatable\begin{tikzpicture}\begin{groupplot}[ group style={rows=2}, width=0.8\textwidth, height=0.4\textwidth, xmajorgrids, ymajorgrids, enlarge x limits=false,] \nextgroupplot[ title={Bode Diagram of $P$}, xmode=log, ylabel={Magnitude / \si{\decibel}}, ] \addplot[blue,line width=2pt] table[x index=0,y index=1]{\datatable}; \nextgroupplot[ xmode=log, xlabel={Frequency / \si{\radian\per\second}}, ylabel={Phase / \si{\degree}}, ] \addplot[red,line width=2pt] table[x index=0,y index=2]{\datatable};\end{groupplot}\end{tikzpicture}\end{document}</syntaxhighlight>}} to generate a beautiful bode diagram [[File:bode_p.png]] Try also (a first order low-pass filter has -3db magnitude at f=1/T1).
=== Inverted Pendulum ===
501

edits

Navigation menu