changeset 11188:5b0c129a01ba octave-forge

control: work on d2c
author paramaniac
date Sun, 28 Oct 2012 20:25:06 +0000
parents 4d4c82f654bb
children be8b9efda07d
files main/control/devel/matched_d2c.m main/control/inst/@tf/__d2c__.m
diffstat 2 files changed, 8 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main/control/devel/matched_d2c.m	Sun Oct 28 20:25:06 2012 +0000
@@ -0,0 +1,5 @@
+numP = [1];
+denP = conv ([1, 1, 1], [1, 4, 6, 4, 1]);
+P = tf (numP, denP);
+
+Pc = d2c (c2d (P, 0.1, 'matched'), 'matched')
\ No newline at end of file
--- a/main/control/inst/@tf/__d2c__.m	Sun Oct 28 18:29:17 2012 +0000
+++ b/main/control/inst/@tf/__d2c__.m	Sun Oct 28 20:25:06 2012 +0000
@@ -37,6 +37,7 @@
       error ("tf: d2c: discrete-time poles and zeros at 0 not supported because log(0) is -Inf");
     endif
 
+    z_d_orig = z_d;
     z_d(abs (z_d+1) < sqrt (eps)) = [];
 
     p_c = log (p_d) / tsam;    
@@ -45,11 +46,11 @@
     w_c = 0;
     w_d = 1;
     tol = sqrt (eps);
-    while (any (abs ([p; z] - w_d) < tol))
+    while (any (abs ([p_d; z_d_orig] - w_d) < tol))
       w_c += 0.1 / tsam;
     endwhile
     w_d = exp (w_c * tsam);
-    k_c = real (k_d * prod (w_d - z) / prod (w_d - p) * prod (w_c - p_c) / prod (w_c - z_c));
+    k_c = real (k_d * prod (w_d - z_d_orig) / prod (w_d - p_d) * prod (w_c - p_c) / prod (w_c - z_c));
 
     tmp = zpk (z_c, p_c, k_c);
     sys.num = tmp.num;