diff options
Diffstat (limited to '2048/DEPENDENCIES/myc2d.sci')
-rw-r--r-- | 2048/DEPENDENCIES/myc2d.sci | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/2048/DEPENDENCIES/myc2d.sci b/2048/DEPENDENCIES/myc2d.sci new file mode 100644 index 000000000..1644cddfe --- /dev/null +++ b/2048/DEPENDENCIES/myc2d.sci @@ -0,0 +1,20 @@ +// Discretization of continuous transfer function. The result is numerator and denominator in powers of z^{-1} and the delay term k.
+// 9.2
+// function [B,A,k] = myc2d(G,Ts)
+// Produces numerator and denominator of discrete transfer
+// function in powers of z^{-1}
+// G is continuous transfer function; time delays are not allowed
+// Ts is the sampling time, all in consistent time units
+
+function [B,A,k] = myc2d(G,Ts)
+H = ss2tf(dscr(G,Ts));
+num1 = coeff(H('num'));
+den1 = coeff(H('den'));//-------------
+A = den1(length(den1):-1:1);
+num2 = num1(length(num1):-1:1); //flip
+nonzero = find(num1);
+first_nz = nonzero(1);
+B = num2(first_nz:length(num2)); //-------------
+k = length(den1) - length(num1);
+endfunction
+
|