summaryrefslogtreecommitdiff
path: root/2048/DEPENDENCIES/pd.sci
diff options
context:
space:
mode:
Diffstat (limited to '2048/DEPENDENCIES/pd.sci')
-rw-r--r--2048/DEPENDENCIES/pd.sci14
1 files changed, 14 insertions, 0 deletions
diff --git a/2048/DEPENDENCIES/pd.sci b/2048/DEPENDENCIES/pd.sci
new file mode 100644
index 000000000..110401281
--- /dev/null
+++ b/2048/DEPENDENCIES/pd.sci
@@ -0,0 +1,14 @@
+// PD control law from polynomial coefficients, as explained in Sec. 9.8.
+// 9.22
+
+function [K,taud,N] = pd(Rc,Sc,Ts)
+
+// Both Rc and Sc have to be degree one polynomials
+
+s0 = Sc(1); s1 = Sc(2);
+r1 = Rc(2);
+K = (s0+s1)/(1+r1);
+N = (s1-s0*r1)/r1/(s0+s1);
+taudbyN = -Ts*r1/(1+r1);
+taud = taudbyN * N;
+endfunction;