This section describes the non-graphic functions of LyME borrowed from SysQuake.
Continuous-to-discrete-time conversion.
(numd,dend) = c2dm(numc,denc,Ts) dend = c2dm(numc,denc,Ts) (numd,dend) = c2dm(numc,denc,Ts,method) dend = c2dm(numc,denc,Ts,method) (Ad,Bd,Cd,Dd) = c2dm(Ac,Bc,Cc,Dc,Ts,method)
(numd,dend) = c2dm(numc,denc,Ts) converts the continuous-time transfer function numc/denc to a discrete-time transfer function numd/dend with sample time Ts. The continuous-time transfer function is given by two polynomials in s, and the discrete-time transfer function is given by two polynomials in z, all as vectors of coefficients with highest powers first.
Method is one of
'zoh' or 'z' | zero-order hold (default) |
'tustin' or 't' | Tustin (bilinear transformation) |
The input and output arguments numc, denc, numd, and dend can also be matrices; in that case, the conversion is applied separately on each row with the same sample time Ts.
c2dm(Ac,Bc,Cc,Dc,Ts,method) performs the conversion from continuous-time state-space model (Ac,Bc,Cc,Dc) to discrete-time state-space model (Ad,Bd,Cd,Dd), defined by
dx/dt = Ac x + Bc u y = Cc x + Dc u
x(k+1) = Ad x(k) + Bd u(k) y(k) = Cd x(k) + Dd u(k)
(numd, dend) = c2dm(1, [1, 1], 5) numd = 0.9933 dend = 1 -6.7379e-3 (numd, dend) = c2dm(1, [1, 1], 5, 'tustin') numd = 0.7143 0.7143 dend = 1 0.4286
Discrete-to-continuous-time conversion.
(numc,denc) = d2cm(numd,dend,Ts) denc = d2cm(numd,dend,Ts) (numc,denc) = d2cm(numd,dend,Ts,method) denc = d2cm(numd,dend,Ts,method)
(numc,denc) = d2cm(numd,dend,Ts,method) converts the discrete-time transfer function numd/dend with sample time Ts to a continuous-time transfer function numc/denc. The continuous-time transfer function is given by two polynomials in s, and the discrete-time transfer function is given by two polynomials in z, all as vectors of coefficients with highest powers first.
Method is
tustin or 't' | Tustin (bilinear transformation) (default) |
The input and output arguments numc, denc, numd, and dend can also be matrices; in that case, the conversion is applied separately on each row with the same sample time Ts.
d2cm(Ad,Bd,Cd,Dd,Ts,method) performs the conversion from discrete-time state-space model (Ad,Bd,Cd,Dd) to continuous-time state-space model (Ac,Bc,Cc,Dc), defined by
x(k+1) = Ad x(k) + Bd u(k) y(k) = Cd x(k) + Dd u(k)
dx/dt = Ac x + Bc u y = Cc x + Dc u
(numd, dend) = c2dm(1, [1, 1], 5, 't') numd = 0.7143 0.7143 dend = 1 0.4286 (numc, denc) = d2cm(numd, dend) numc = -3.8858e-17 1 denc = 1 1
Conversion from state space to transfer function.
(num,den) = ss2tf(A,B,C,D) den = ss2tf(A,B,C,D) (num,den) = ss2tf(A,B,C,D,iu) den = ss2tf(A,B,C,D,iu)
A continuous-time linear time-invariant system can be represented by the state-space model
dx/dt = A x + B u y = C x + D u
where
For a sampled-time model, exactly the same function can be used. The derivative
is replaced by a forward shift, and the variable
The degree of the denominator is equal to the number of states, i.e. the size of A. The degree of the numerator is equal to the number of states if D is not null, and one less if D is null.
(num, den) = ss2tf(-1, 1, 1, 0) num = 1 den = 1 1
Conversion from transfer function to state space.
(A,B,C,D) = tf2ss(num,den)
tf2ss(num,den) returns the state-space representation of the transfer function num/den, which is given as two polynomials. The transfer function must be causal, i.e. num must not have more columns than den. Systems with several outputs are specified by a num having one row per output; the denominator den must be the same for all the outputs.
tf2ss applies to continuous-time systems (Laplace transform) as well as to discrete-time systems (z transform or delta transform).
(A,B,C,D) = tf2ss([2,5],[2,3,8]) A = -1.5 -4 1 0 B = 1 0 C = 1 2.5 D = 0