Control package: Difference between revisions

48 bytes added ,  29 September 2015
Line 471: Line 471:
==== Bode Diagram for TikZ/PGFplots ====
==== 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.
We use the same system as before but we draw now with <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.
The output is written to a .csv file.


<!-- {{SyntaxHighlight| -->
<!-- {{SyntaxHighlight| -->
{{Code|Creating a transfer function and plotting its response|<syntaxhighlight lang="octave" style="font-size:14px">
{{Code|Creating a transfer function and calculating its bode diagram|<syntaxhighlight lang="octave" style="font-size:14px">
T1 = 0.4;              # time constant
T1 = 0.4;              # time constant
P = tf([1], [T1 1]);
P = tf([1], [T1 1]);


[mag, pha, w] = bode(P);
[mag, pha, w] = bode(P);


csvwrite("dat/bode_p.csv", [w', 20*log10(mag), pha]);
csvwrite("dat/bode_p.csv", [w', 20*log10(mag), pha]);
</syntaxhighlight>}}
</syntaxhighlight>}}


Line 487: Line 487:


<!-- {{SyntaxHighlight| -->
<!-- {{SyntaxHighlight| -->
{{Code|Creating a transfer function and plotting its response|<syntaxhighlight lang="latex" style="font-size:14px">
{{Code|Creating a bode diagram with pgfplots|<syntaxhighlight lang="latex" style="font-size:14px">
\documentclass[tikz]{standalone}
\documentclass[tikz]{standalone}
\usepackage{pgfplotstable}
\usepackage{pgfplotstable}
Line 525: Line 525:
[[File:bode_p.png]]
[[File:bode_p.png]]


Try also  (a first order low-pass filter has -3db magnitude at f=1/T1).
It can be seen that a first order low-pass filter has <math display="inline">-3\,db</math> magnitude at <math display="inline">f=1/T_1</math>.


=== Inverted Pendulum ===
=== Inverted Pendulum ===
501

edits