Library - lti

Library lti defines methods related to objects which represent linear time-invariant dynamical systems. LTI systems may be used to model many different systems: electro-mechanical devices, robots, chemical processes, filters, etc. LTI systems map one or more inputs u to one or more outputs y. The mapping is defined as a state-space model or as a matrix of transfer functions, either in continuous time or in discrete time. Methods are provided to create, combine, and analyze LTI objects.

Graphical methods are based on the corresponding graphical functions; the numerator and denominator coefficient vectors or the state-space matrices are replaced with an LTI object. They accept the same optional arguments, such as a character string for the style.

The following statement makes available functions defined in lti:

use lti

ss::ss

LTI state-space constructor.

Syntax

a = ss
a = ss(A, B, C, D)
a = ss(A, B, C, D, Ts)
a = ss(A, B, C, D, Ts, var)
a = ss(A, B, C, D, b)
a = ss(b)

Description

ss(A,B,C,D) creates an LTI object which represents the continuous-time state-space model

x'(t) = A x(t) + B u(t)
y(t)  = C x(t) + D u(t)

ss(A,B,C,D,Ts) creates an LTI object which represents the discrete-time state-space model with sampling period Ts

x(k+1) = A x(k) + B u(k)
y(k)   = C x(k) + D u(k)

In both cases, if D is 0, it is resized to match the size of B and C if necessary. An additional argument var may be used to specify the variable of the Laplace ('s' (default) or 'p') or z transform ('z' (default) or 'q').

ss(A,B,C,D,b), where b is an LTI object, creates a state-space model of the same kind (continuous/discrete time, sampling time and variable) as b.

ss(b) converts the LTI object b to a state-space model.

Examples

sc = ss(-1, [1,2], [2;5], 0)
  sc =
    continuous-time LTI state-space system
    A =
        -1
    B =
         1     2
    C =
         2
         5
    D =
         0     0
         0     0
sd = ss(tf(1,[1,2,3,4],0.1))
  sd =
    discrete-time LTI state-space system, Ts=0.1
    A =
      -2    -3    -4
       1     0     0
       0     1     0
    B =
       1
       0
       0
    C =
       0     0     1
    D =
       0

See also

tf

tf::tf

LTI transfer function constructor.

Syntax

a = tf
a = tf(num, den)
a = tf(numlist, denlist)
a = tf(..., Ts)
a = tf(..., Ts, var)
a = tf(..., b)
a = tf(gain)
a = tf(b)

Description

tf(num,den) creates an LTI object which represents the continuous-time transfer function specified by descending-power coefficient vectors num and den. tf(num,den,Ts) creates an LTI object which represents a discrete-time transfer function with sampling period Ts.

In both cases, num and den may be replaced with cell arrays of coefficients whose elements are the descending-power coefficient vectors. The number of rows is the number of system outputs, and the number of columns is the number of system inputs.

An additional argument var may be used to specify the variable of the Laplace ('s' (default) or 'p') or z transform ('z' (default) or 'q').

tf(...,b), where b is an LTI object, creates a transfer function of the same kind (continuous/discrete time, sampling time and variable) as b.

tf(b) converts the LTI object b to a transfer function.

tf(gain), where gain is a matrix, creates a matrix of gains.

Examples

Simple continuous-time system with variable p (p is used only for display):

sc = tf(1,[1,2,3,4],'p')
  sc =
    continuous-time transfer function
    1/(p^3+2p^2+3p+4)

Matrix of discrete-time transfer functions for one input and two outputs, with a sampling period of 1ms:

sd = tf({0.1; 0.15}, {[1, -0.8]; [1; -0.78]}, 1e-3)
  sd =
    discrete-time transfer function, Ts=1e-3
    y1/u1: 0.1/(s-0.8)
    y2/u1: 0.15/(s-0.78)

See also

ss

lti::append

Append the inputs and outputs of systems.

Syntax

b = append(a1, a2, ...)

Description

append(a1,a2) builds a system with inputs [u1;u2] and outputs [y1;y2], where u1 and u2 are the inputs of a1 and y1 and y2 their outputs, respectively. append accepts any number of input arguments.

See also

connect

ss::augstate

Extend the output of a system with its states.

Syntax

b = augstate(a)

Description

augstate(a) extends the ss object a by adding its states to its outputs. The new output yext is [y;x], where y is the output of a and x is its states.

lti::beginning

First index.

Syntax

var(...beginning...)

Description

In an expression used as an index between parenthesis, beginning(a) gives the first valid value for an index. It is always 1.

See also

end, subsasgn, subsref

lti::c2d

Conversion from continuous time to discrete time.

Syntax

b = c2d(a, Ts)
b = c2d(a, Ts, method)

Description

c2d(a,Ts) converts the continuous-time system a to a discrete-time system with sampling period Ts.

c2d(a,Ts,method) uses the specified conversion method. method is one of the methods supported by c2dm.

See also

d2c, c2dm

lti::connect

Arbitrary feedback connections.

Syntax

b = connect(a, links, in, out)

Description

connect(a,links,in,out) modifies lti object a by connecting some of the outputs to some of the inputs and by keeping some of the inputs and some of the outputs. Connections are specified by the rows of matrix link. In each row, the first element is the index of the system input where the connection ends; other elements are indices to system outputs which are summed. The sign of the indices to outputs gives the sign of the unit weight in the sum. Zeros are ignored. Arguments in and out specify which input and output to keep.

See also

feedback

lti::d2c

Conversion from discrete time to continuous time.

Syntax

b = d2c(a)
b = d2c(a, method)

Description

d2c(a) converts the discrete-time system a to a continuous-time system.

d2c(a,method) uses the specified conversion method. method is one of the methods supported by d2cm.

See also

c2d, d2cm

lti::end

Last index.

Syntax

var(...end...)

Description

In an expression used as an index between parenthesis, end gives the last valid value for that index. It is size(var,1) or size(var,2).

Example

Time response when the last input is a step:

P = ss([1,2;-3,-4],[1,0;0,1],[3,5]);
P1 = P(:, end)
  continuous-time LTI state-space system
  A =
     1   2
    -3  -4
  B =
     0
     1
  C =
     3   5
  D =
     0
step(P1);

See also

beginning, subsasgn, subsref

lti::evalfr

Frequency value.

Syntax

y = evalfr(a, x)

Description

evalfr(a,x) evaluates system a at complex value or values x. If x is a vector of values, results are stacked along the third dimension.

Example

sys = [tf(1, [1,2,3]), tf(2, [1,2,3,4])];
evalfr(sys, 0:1j:3j)
  ans =
    1x2x4 array
    (:,:,1) =
      0.3333                  0.5         
    (:,:,2) =
      0.25     -0.25j         0.5      -0.5j
    (:,:,3) =
     -5.8824e-2-0.2353j      -0.4      +0.2j
    (:,:,4) =
     -8.3333e-2-8.3333e-2j   -5.3846e-2+6.9231e-2j

See also

polyval

ss::ctrb

Controllability matrix.

Syntax

C = crtb(a)

Description

ctrb(a) gives the controllability matrix of system a, which is full-rank if and only if a is controllable.

See also

obsv

lti::dcgain

Steady-state gain.

Syntax

g = dcgain(a)

Description

dcgain(a) gives the steady-state gain of system a.

See also

norm

lti::feedback

Feedback connection.

Syntax

c = feedback(a, b)
c = feedback(a, b, sign)
c = feedback(a, b, ina, outa)
c = feedback(a, b, ina, outa, sign)

Description

feedback(a,b) connects all the outputs of lti object a to all its inputs via the negative feedback lti object b.

feedback(a,b,sign) applies positive feedback with weight sign; the default value of sign is -1.

feedback(a,b,ina,outa) specifies which inputs and outputs of a to use for feedback. The inputs and outputs of the result always correspond to the ones of a.

See also

connect

lti::inv

System inverse.

Syntax

b = inv(a)

Description

inv(a) gives the inverse of system a.

See also

mldivide, mrdivide

lti::isct

Test for a continous-time LTI.

Syntax

b = isct(a)

Description

isct(a) is true if system a is continuous-time or static, and false otherwise.

See also

isdt

lti::isdt

Test for a discrete-time LTI.

Syntax

b = isdt(a)

Description

isdt(a) is true if system a is discrete-time or static, and false otherwise.

See also

isct

lti::isempty

Test for an LTI without input/output.

Syntax

b = isempty(a)

Description

isempty(a) is true if system a has no input and/or no output, and false otherwise.

See also

size, issiso

lti::isproper

Test for a proper (causal) LTI.

Syntax

b = isproper(a)

Description

isproper(a) is true if lti object a is causal, or false otherwise. An ss object is always causal. A tf object is causal if all the transfer functions are proper, i.e. if the degrees of the denominators are at least as large as the degrees of the numerators.

lti::issiso

Test for a single-input single-output LTI.

Syntax

b = issiso(a)

Description

issiso(a) is true if lti object a has one input and one output (single-input single-output system, or SISO), or false otherwise.

size, isempty

lti::minreal

Minimum realization.

Syntax

b = minreal(a)
b = minreal(a, tol)

Description

minreal(a) modifies lti object a in order to remove states which are not controllable and/or not observable. For tf objects, identical zeros and poles are canceled out.

minreal(a,tol) uses tolerance tol to decide whether to discard a state or a pair of pole/zero.

lti::minus

System difference.

Syntax

c = a - b
c = minus(a, b)

Description

a-b computes the system whose inputs are fed to both a and b and whose outputs are the difference between outputs of a and b. If a and b are transfer functions or matrices of transfer functions, this is equivalent to a difference of matrices.

See also

parallel, plus, uminus

lti::mldivide

System left division.

Syntax

c = a \ b
c = mldivide(a, b)

Description

a/b is equivalent to inv(a)*b.

See also

mrdivide, times, inv

lti::mrdivide

System right division.

Syntax

c = a / b
c = mrdivide(a, b)

Description

a/b is equivalent to a*inv(b).

See also

mldivide, times, inv

lti::mtimes

System product.

Syntax

c = a * b
c = mtimes(a, b)

Description

a*b connects the outputs of lti object b to the inputs of lti object a. If a and b are transfer functions or matrices of transfer functions, this is equivalent to a product of matrices.

See also

series

lti::norm

H2 norm.

Syntax

h2 = norm(a)

Description

norm(a) gives the H2 norm of the system a.

See also

dcgain

ss::obsv

Observability matrix.

Syntax

O = obsv(a)

Description

obsv(a) gives the observability matrix of system a, which is full-rank if and only if a is observable.

See also

ctrb

lti::parallel

Parallel connection.

Syntax

c = parallel(a, b)
c = parallel(a, b, ina, inb, outa, outb)

Description

parallel(a,b) connects lti objects a and b in such a way that the inputs of the result is applied to both a and b, and the outputs of the result is their sum.

parallel(a,b,ina,inb,outa,outb) specifies which inputs are shared between a and b, and which outputs are summed. The inputs of the result are partitioned as [ua,uab,ub] and the outputs as [ya,yab,yb]. Inputs uab are fed to inputs ina of a and inb of b; inputs ua are fed to the remaining inputs of a, and ub to the remaining inputs of b. Similarly, outputs yab are the sum of outputs outa of a and outputs outb of b, and ya and yb are the remaining outputs of a and b, respectively.

See also

series

lti::plus

System sum.

Syntax

c = a + b
c = plus(a, b)

Description

a+b computes the system whose inputs are fed to both a and b and whose outputs are the sum of the outputs of a and b. If a and b are transfer functions or matrices of transfer functions, this is equivalent to a sum of matrices.

See also

parallel, minus

lti::series

Series connection.

Syntax

c = series(a, b)
c = series(a, b, outa, inb)

Description

series(a,b) connects the outputs of lti object a to the inputs of lti object b.

series(a,b,outa,inb) connects outputs outa of a to inputs inb of b. Unconnected outputs of a and inputs of b are discarded.

See also

mtimes, parallel

lti::repmat

Replicate a system.

Syntax

b = repmat(a, n)
b = repmat(a, [m,n])
b = repmat(a, m, n)

Description

repmat(a,n), when a is a transfer function or a matrix of transfer functions, creates a new system described by a matrix of transfer functions where a is repeated n times horizontally and vertically. If a is a state-space system, matrices B, C, and D are replicated to obtain the same effect.

repmat(a,[m,n]) or repmat(a,m,n) repeats matrix a m times vertically and n times horizontally.

See also

append

lti::size

Number of outputs and inputs.

Syntax

s = size(a)
(nout, nin) = size(a)
n = size(a, dim)

Description

With one output argument, size(a) gives the row vector [nout,nin], where nout is the number of outputs of system a and nin its number of inputs. With two output arguments, size(a) returns these results separately as scalars.

size(a,1) gives only the number of outputs, and size(a,2) only the number of inputs.

See also

isempty, issiso

lti::ssdata

Get state-space matrices.

Syntax

(A, B, C, D) = ssdata(a)
(A, B, C, D, Ts) = ssdata(a)

Description

ssdata(a), where a is any kind of LTI object, gives the four matrices of the state-space model, and optionally the sampling period or the empty array [] for continuous-time systems.

See also

tfdata

lti::subsasgn

Assignment to a part of an LTI system.

Syntax

var(i,j) = a
var(ix) = a
var(select) = a
var.field = value
a = subsasgn(a, s, b)

Description

The method subsasgn(a) permits the use of all kinds of assignments to a part of an LTI system. If the variable is a matrix of transfer functions, subsasgn produces the expected result, converting the right-hand side of the assignment to a matrix of transfer function if required. If the variable is a state-space model, the result is equivalent; the result remains a state-space model. For state-space models, changing all the inputs or all the outputs with the syntax var(expr,:)=sys or var(:,expr)=sys is much more efficient than specifying both subscripts or a single index.

The syntax for field assignment, var.field=value, is defined for the following fields: for state-space models, A, B, C, and D (matrices of the state-space model); for transfer functions, num and den (cell arrays of coefficients); for both, var (string) and Ts (scalar, or empty array for continuous-time systems). Field assignment must preserve the size of matrices and arrays.

The syntax with braces (var{i}=value) is not supported.

See also

subsref, operator (), subsasgn

lti::subsref

Extraction of a part of an LTI system.

Syntax

var(i,j)
var(ix)
var(select)
var.field
b = subsref(a, s)

Description

The method subsref(a) permits the use of all kinds of extraction of a part of an LTI system. If the variable is a matrix of transfer functions, subsref produces the expected result. If the variable is a state-space model, the result is equivalent; the result remains a state-space model. For state-space models, extracting all the inputs or all the outputs with the syntax var(expr,:) or var(:,expr) is much more efficient than specifying both subscripts or a single index.

The syntax for field access, var.field, is defined for the following fields: for state-space models, A, B, C, and D (matrices of the state-space model); for transfer functions, num and den (cell arrays of coefficients); for both, var (string) and Ts (scalar, or empty array for continuous-time systems).

The syntax with braces (var{i}) is not supported.

See also

subsasgn, operator (), subsasgn

lti::tfdata

Get transfer functions.

Syntax

(num, den) = tfdata(a)
(num, den, Ts) = ssdata(a)

Description

tfdata(a), where a is any kind of LTI object, gives the numerator and denominator of the transfer function model, and optionally the sampling period or the empty array [] for continuous-time systems. The numerators and denominators are given as a cell array of power-descending coefficient vectors; the rows of the cell arrays correcpond to the outputs, and their columns to the inputs.

See also

ssdata

zpk

LTI transfer function constructor using zeros and poles.

Syntax

a = zpk(z, p, k)
a = zpk(zeroslist, poleslist, gainlist)
a = zpk(..., Ts)
a = zpk(..., Ts, var)
a = zpk(..., b)
a = zpk(b)

Description

zpk creates transfer-function LTI systems like tf. Instead of using transfer function coefficients as input, it accepts a vector of zeros, a vector of poles, and a gain for a simple-input simple-output (SISO) system; or lists of sublists of zeros, poles and gains for multiple-input multiple-output (MIMO) systems.

Examples

sd = zpk(0.3, [0.8+0.5j; 0.8-0.5j], 10, 0.1)
  sd =
    discrete-time transfer function, Ts=0.1
    (10z-3)/(z^2-1.6z+0.89)

See also

tf::tf

lti::bodemag

Magnitude of the Bode plot.

Syntax

bodemag(a, ...)
... = bodemag(a, ...)

Description

bodemag(a) plots the magnitude of the Bode diagram of system a.

See also

bodephase, nichols, nyquist

lti::bodephase

Phase of the Bode plot.

Syntax

bodephase(a, ...)
... = bodephase(a, ...)

Description

bodephase(a) plots the magnitude of the Bode diagram of system a.

See also

bodemag, nichols, nyquist

lti::impulse

Impulse response.

Syntax

impulse(a, ...)
... = impulse(a, ...)

Description

impulse(a) plots the impulse response of system a.

See also

step, lsim, initial

lti::initial

Time response with initial conditions.

Syntax

initial(a, x0, ...)
... = initial(a, x0, ...)

Description

initial(a,x0) plots the time response of state-space system a with initial state x0 and null input.

See also

impulse, step, lsim

lti::lsim

Time response.

Syntax

lsim(a, u, t, ...)
... = lsim(a, u, t)

Description

lsim(a,u,t) plots the time response of system a. For continuous-time systems, The input is piece-wise linear; it is defined by points in real vectors t and u, which must have the same length. Input before t(1) and after t(end) is 0. For discrete-time systems, u is sampled at the rate given by the system, and t is ignored or can be omitted.

See also

impulse, step, initial

lti::nichols

Nichols plot.

Syntax

nichols(a, ...)
... = nichols(a, ...)

Description

nichols(a) plots the Nichols diagram of system a.

See also

nyquist, bodemag, bodephase

lti::nyquist

Nyquist plot.

Syntax

nyquist(a, ...)
... = nyquist(a, ...)

Description

nyquist(a) plots the Nyquist diagram of system a.

See also

nichols, bodemag, bodephase

lti::step

Step response.

Syntax

step(a, ...)
... = step(a, ...)

Description

step(a) plots the step response of system a.

See also

impulse, lsim, initial

lti::uminus

Negative.

Syntax

b = -a
b = uminus(a)

Description

-a multiplies all the outputs (or all the inputs) of system a by -1. If a is a transfer functions or a matrix of transfer functions, this is equivalent to the unary minus.

See also

minus, uplus

lti::uplus

Negative.

Syntax

b = +a
b = uplus(a)

Description

+a gives a.

See also

uminus, plus


Copyright 2001-2007, Calerga.
All rights reserved.