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
LTI state-space constructor.
use lti 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)
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.
use lti 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
LTI transfer function constructor.
use lti 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)
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.
Simple continuous-time system with variable p (p is used only for display):
use lti 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)
Append the inputs and outputs of systems.
use lti b = append(a1, a2, ...)
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.
Extend the output of a system with its states.
use lti b = augstate(a)
augstate(a) extends the ss object a by adding its states to its outputs. The new output is [y;x], where y is the output of a and x is its states.
First index.
use lti var(...beginning...)
In an expression used as an index between parenthesis, beginning(a) gives the first valid value for an index. It is always 1.
lti::end, lti::subsasgn, lti::subsref
Conversion from continuous time to discrete time.
use lti b = c2d(a, Ts) b = c2d(a, Ts, method)
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.
Arbitrary feedback connections.
use lti b = connect(a, links, in, out)
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.
Conversion from discrete time to continuous time.
use lti b = d2c(a) b = d2c(a, method)
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.
Last index.
use lti var(...end...)
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).
Time response when the last input is a step:
use lti 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);
lti::beginning, lti::subsasgn, lti::subsref
Frequency value.
use lti y = evalfr(a, x)
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.
use lti 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
Controllability matrix.
use lti C = crtb(a)
ctrb(a) gives the controllability matrix of system a, which is full-rank if and only if a is controllable.
Steady-state gain.
use lti g = dcgain(a)
dcgain(a) gives the steady-state gain of system a.
Feedback connection.
use lti c = feedback(a, b) c = feedback(a, b, sign) c = feedback(a, b, ina, outa) c = feedback(a, b, ina, outa, sign)
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.
System inverse.
use lti b = inv(a)
inv(a) gives the inverse of system a.
Test for a continous-time LTI.
use lti b = isct(a)
isct(a) is true if system a is continuous-time or static, and false otherwise.
Test for a discrete-time LTI.
use lti b = isdt(a)
isdt(a) is true if system a is discrete-time or static, and false otherwise.
Test for an LTI without input/output.
use lti b = isempty(a)
isempty(a) is true if system a has no input and/or no output, and false otherwise.
Test for a proper (causal) LTI.
use lti b = isproper(a)
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.
Test for a single-input single-output LTI.
use lti b = issiso(a)
issiso(a) is true if lti object a has one input and one output (single-input single-output system, or SISO), or false otherwise.
Minimum realization.
use lti b = minreal(a) b = minreal(a, tol)
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.
System difference.
use lti c = a - b c = minus(a, b)
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.
lti::parallel, lti::plus, lti::uminus
System left division.
use lti c = a \ b c = mldivide(a, b)
a/b is equivalent to inv(a)*b.
lti::mrdivide, lti::times, lti::inv
System right division.
use lti c = a / b c = mrdivide(a, b)
a/b is equivalent to a*inv(b).
lti::mldivide, lti::times, lti::inv
System product.
use lti c = a * b c = mtimes(a, b)
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.
H2 norm.
use lti h2 = norm(a)
norm(a) gives the H2 norm of the system a.
Observability matrix.
use lti O = obsv(a)
obsv(a) gives the observability matrix of system a, which is full-rank if and only if a is observable.
Parallel connection.
use lti c = parallel(a, b) c = parallel(a, b, ina, inb, outa, outb)
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.
System sum.
use lti c = a + b c = plus(a, b)
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.
Series connection.
use lti c = series(a, b) c = series(a, b, outa, inb)
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.
Replicate a system.
use lti b = repmat(a, n) b = repmat(a, [m,n]) b = repmat(a, m, n)
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.
Number of outputs and inputs.
use lti s = size(a) (nout, nin) = size(a) n = size(a, dim)
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.
Get state-space matrices.
use lti (A, B, C, D) = ssdata(a) (A, B, C, D, Ts) = ssdata(a)
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.
Assignment to a part of an LTI system.
use lti var(i,j) = a var(ix) = a var(select) = a var.field = value a = subsasgn(a, s, b)
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.
lti::subsref, operator (), subsasgn
Extraction of a part of an LTI system.
use lti var(i,j) var(ix) var(select) var.field b = subsref(a, s)
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.
lti::subsasgn, operator (), subsasgn
Get transfer functions.
use lti (num, den) = tfdata(a) (num, den, Ts) = ssdata(a)
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.
Negative.
use lti b = -a b = uminus(a)
-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.
Negative.
use lti b = +a b = uplus(a)
+a gives a.
LTI transfer function constructor using zeros and poles.
use lti a = zpk(z, p, k) a = zpk(zeroslist, poleslist, gainlist) a = zpk(..., Ts) a = zpk(..., Ts, var) a = zpk(..., b) a = zpk(b)
zpk creates transfer-function LTI systems like tf::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.
use lti 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)
Magnitude of the Bode plot.
use lti bodemag(a, ...) ... = bodemag(a, ...)
bodemag(a) plots the magnitude of the Bode diagram of system a.
lti::bodephase, lti::nichols, lti::nyquist
Phase of the Bode plot.
use lti bodephase(a, ...) ... = bodephase(a, ...)
bodephase(a) plots the magnitude of the Bode diagram of system a.
lti::bodemag, lti::nichols, lti::nyquist
Impulse response.
use lti impulse(a, ...) ... = impulse(a, ...)
impulse(a) plots the impulse response of system a.
lti::step, lti::lsim, lti::initial
Time response with initial conditions.
use lti initial(a, x0, ...) ... = initial(a, x0, ...)
initial(a,x0) plots the time response of state-space system a with initial state x0 and null input.
lti::impulse, lti::step, lti::lsim
Time response.
use lti lsim(a, u, t, ...) ... = lsim(a, u, t)
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.
lti::impulse, lti::step, lti::initial
Nichols plot.
use lti nichols(a, ...) ... = nichols(a, ...)
nichols(a) plots the Nichols diagram of system a.
lti::nyquist, lti::bodemag, lti::bodephase
Nyquist plot.
use lti nyquist(a, ...) ... = nyquist(a, ...)
nyquist(a) plots the Nyquist diagram of system a.
lti::nichols, lti::bodemag, lti::bodephase
Step response.
use lti step(a, ...) ... = step(a, ...)
step(a) plots the step response of system a.