en fr

Sysquake Pro – Table of Contents

Sysquake – Table of Contents

Sysquake for LaTeX – Table of Contents

Dynamical System Functions

This section describes functions related to linear time-invariant dynamical systems.

c2dm

Continuous-to-discrete-time conversion.

Syntax

(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)

Description

(numd,dend) = c2dm(numc,denc,Ts) converts the continuous-time transfer function numc/denc to a discrete-time transfer function numd/dend with sampling period 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.

c2dm(numc,denc,Ts,method) uses the specified conversion method. method is one of

MethodDescription
'zoh' or 'z' zero-order hold (default)
'foh' or 'f' first-order hold
'tustin' or 't' Tustin (bilinear transformation)
'matched' or 'm' Matched zeros, poles and gain

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 sampling period 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

and

x(k+1) = Ad x(k) + Bd u(k)
y(k)   = Cd x(k) + Dd u(k)

Method 'matched' is not supported for state-space models.

Examples

(numd, dend) = c2dm(1, [1, 1], 0.1)
  numd =
    0.0952
  dend =
    1 -0.9048
(numd, dend) = c2dm(1, [1, 1], 0.1, 'foh')
  numd =
    0.0484
  dend =
    1 -0.9048
(numd, dend) = c2dm(1, [1, 1], 0.1, 'tustin')
  numd =
    0.0476 0.0476
  dend =
    1 -0.9048

See also

d2cm

d2cm

Discrete-to-continuous-time conversion.

Syntax

(numc,denc) = d2cm(numd,dend,Ts)
denc = d2cm(numd,dend,Ts)
(numc,denc) = d2cm(numd,dend,Ts,method)
denc = d2cm(numd,dend,Ts,method)

Description

(numc,denc) = d2cm(numd,dend,Ts,method) converts the discrete-time transfer function numd/dend with sampling period 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

MethodDescription
'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 sampling period 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)

and

dx/dt = Ac x + Bc u
y     = Cc x + Dc u

Example

(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

See also

c2dm

dmargin

Robustness margins of a discrete-time system.

Syntax

(gm,psi,wc,wx) = dmargin(num,den,Ts)
(gm,psi,wc,wx) = dmargin(num,den)

Description

The open-loop discrete-time transfer function is given by the two polynomials num and den, with sampling period Ts (default value is 1). If the closed-loop system (with negative feedback) is unstable, all output arguments are set to an empty matrix. Otherwise, dmargin calculates the gain margins gm, which give the interval of gain for which the closed-loop system remains stable; the phase margin psi, always positive if it exists, which defines the symmetric range of phases which can be added to the open-loop system while keeping the closed-loop system stable; the critical frequency associated to the gain margins, where the open-loop frequency response intersects the real axis around -1; and the cross-over frequency associated to the phase margin, where the open-loop frequency response has a unit magnitude. If the Nyquist diagram does not cross the unit circle, psi and wx are empty.

Examples

Stable closed-loop, Nyquist inside unit circle:

(gm,psi,wc,wx) = dmargin(0.005,poly([0.9,0.9]))
  gm = [-2, 38]
  psi = []
  wc = [0, 0.4510]
  wx = []

Stable closed-loop, Nyquist crosses unit circle:

(gm,psi,wc,wx) = dmargin(0.05,poly([0.9,0.9]))
  gm = [-0.2, 3.8]
  psi = 0.7105
  wc = [0, 0.4510]
  wx = 0.2112

Unstable closed-loop:

(gm,psi,wc,wx) = dmargin(1,poly([0.9,0.9]))
  gm = []
  psi = []
  wc = []
  wx = []

Caveats

Contrary to many functions, dmargin cannot be used with several transfer functions simultaneously, because not all of them may correspond simultaneously to either stable or unstable closed-loop systems.

See also

margin

margin

Robustness margins of a continuous-time system.

Syntax

(gm,psi,wc,wx) = margin(num,den)

Description

The open-loop continuous-time transfer function is given by the two polynomials num and den. If the closed-loop system (with negative feedback) is unstable, all output arguments are set to an empty matrix. Otherwise, margin calculates the gain margins gm, which give the interval of gain for which the closed-loop system remains stable; the phase margin psi, always positive if it exists, which defines the symmetric range of phases which can be added to the open-loop system while keeping the closed-loop system stable; the critical frequency associated to the gain margins, where the open-loop frequency response intersects the real axis around -1; and the cross-over frequency associated to the phase margin, where the open-loop frequency response has a unit magnitude. If the Nyquist diagram does not cross the unit circle, psi and wx are empty.

Examples

Stable closed-loop, Nyquist inside unit circle:

(gm,psi,wc,wx) = margin(0.5,poly([-1,-1,-1]))
  gm = [-2, 16]
  psi = []
  wc = [0, 1.7321]
  wx = []

Stable closed-loop, Nyquist crosses unit circle:

(gm,psi,wc,wx) = margin(4,poly([-1,-1,-1]))
  gm = [-0.25 2]
  psi = 0.4737
  wc = [0, 1.7321]
  wx = 1.2328

Unstable closed-loop:

(gm,psi,wc,wx) = margin(10,poly([-1,-1,-1]))
  gm = []
  psi = []
  wc = []
  wx = []

Caveats

Contrary to many functions, margin cannot be used with several transfer functions simultaneously, because not all of them may correspond simultaneously to either stable or unstable closed-loop systems.

See also

dmargin

movezero

Change the position of a real or complex zero in a real-coefficient polynomial.

Syntax

pol2 = movezero(pol1, p0, p1)
(pol2, p1actual) = movezero(pol1, p0, p1)

Description

movezero should be used in the mousedrag handle when the user drags the zero of a polynomial with real coefficients. It insures a consistent user experience.

If p0 is a real or complex zero of the polynomial pol1, movezero computes a new polynomial pol2, with real coefficients, a zero at p1, and most other zeros unchanged. If p0 and p1 are real,

pol2 = conv(deconv(pol1, [1, -p0]), [1, -p1])

If p0 and p1 are complex and their imaginary part has the same sign,

pol2 = conv(deconv(pol1, poly([p0,conj(p0)])), ...
            poly([p1,conj(p1)]))

Otherwise, a real pole p0 is moved to complex pole p1 if imag(p1) > 0 and there is another real pole in pol0. A complex pole p0 can be moved to real(p1) if imag(p1)*imag(p0) < 0; in that case, conj(p0) is moved to real(p0).

If it exists, the second output argument is set to the actual value of the displaced pole. It can be used to provide feedback to the user during the drag.

Examples

roots(movezero(poly([1,3,2+3j,2-3j]),1,5))
  5
  3
  2+3j
  2-3j
roots(movezero(poly([1,3,2+3j,2-3j]),1,2j))
  2j
  -2j
  2+3j
  2-3j
roots(movezero(poly([1,3,2+3j,2-3j]),2+3j,5+8j))
  1
  3
  5+8j
  5-8j
roots(movezero(poly([1,3,2+3j,2-3j]),2+3j,5-8j))
  1
  3
  5
  2
(pol, newPole) = movezero(poly([1,3,2+3j,2-3j]),2+3j,5-8j);
newPole
  5

See also

roots, conv, deconv

ss2tf

Conversion from state space to transfer function.

Syntax

(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)

Description

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 x is the state, u the input, y the output, and ABCD four constant matrices which characterize the model. If it is a single-input single-output system, it can also be represented by its transfer function num/den. (num,den) = ss2tf(A,B,C,D) converts the model from state space to transfer function. If the state-space model has multiple outputs, num is a matrix whose lines correspond to each output (the denominator is the same for all outputs). If the state-space model has multiple inputs, a fifth input argument is required and specifies which one to consider.

For a sampled-time model, exactly the same function can be used. The derivative is replaced by a forward shift, and the variable s of the Laplace transform is replaced by the variable z of the z transform. But as long as coefficients are concerned, the conversion is the same.

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 zero, and one less if D is zero.

If D is zero, it can be replaced by the empty matrix [].

Example

Conversion from the state-space model dx/dt=-x+u, y=x to the transfer function Y(s)/U(s)=1/(s+1):

(num, den) = ss2tf(-1, 1, 1, 0)
  num =
    1
  den =
    1 1

See also

tf2ss

tf2ss

Conversion from transfer function to state space.

Syntax

(A,B,C,D) = tf2ss(num,den)

Description

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).

Example

(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

See also

ss2tf, zp2ss

zp2ss

Conversion from transfer function given by zeros and poles to state space.

Syntax

(A,B,C,D) = zp2ss(z,p,k)

Description

zp2ss(z,p,k) returns the state-space representation of the transfer function with zeros z, poles p and gain k (ratio of leading coefficients of numerator and denominator in decreasing powers). The transfer function must be causal, i.e. the number of zeros must not be larger than the number of poles. zp2ss supports only systems with one input and one output. Complex zeros and complex poles must make complex conjugate pairs, so that the corresponding polynomials have real coefficients.

zp2ss applies to continuous-time systems (Laplace transform) as well as to discrete-time systems (z transform or delta transform).

Example

(A,B,C,D) = zp2ss([1;2],[3;4-1j;4+1j],5)
  A =
    8  -17    1
    1    0    0
    0    0    3
  B =
    0
    0
    1
  C =
   25  -75    5
  D =
    0

See also

tf2ss