blob: 1644cddfe53d087ab755bf8f4b0e9061a7d27646 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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
|