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
Methods for conversion to MathML are defined in library lti_mathml. Both libraries can be loaded with a single statement:
use lti, lti_mathml
The LTI library defines six classes. The three central ones correspond to the main model structures used for linear time-invariant systems in automatic control: ss for state-space models, tf for rational transfer functions given by the coefficients of the numerator and denominator polynomials, and zpk for rational transfer functions given by their zeros, poles and gain. State-space representation is restricted to causal systems, while transfer functions can be non-causal. Three additional classes are more specialized: frd (frequency response data) for systems described by a discrete set of frequency/complex response pairs, and pid or pidstd for PID controllers.
LTI classes share many properties and methods. They can represent systems with single or multiple inputs and/or outputs. Inputs, outputs and internal states are continuous in time (continuous-time systems) or defined at a fixed sampling frequency (discrete-time systems).
The variable of the Laplace transform can be 's' or 'p'. The variable of the z transform can be 'z' or 'q'. By multiplying the numerator and the denominator of a rational transfer function by a suitable power of q^-1 (or z^-1), polynomials in q^-1 can be obtained, where q^-1 is the delay operator; this yields directly a recurrence relation.
Conversion between ss, tf and zpk can be done simply by calling the target constructor. The only restriction is that systems to be converted to state-space models must be causal. For instance, a transfer function given by its zeros, poles and gain can be converted to a state-space model as follows:
use lti; P = zpk([1], [-3+1j, -3-1j], 2) P = continuous-time zero-pole-gain transfer function 2(s-1)/(s-(-3+1j))(s-(-3-1j)) S = ss(P) S = continuous-time LTI state-space system A = -6 -10 1 0 B = 1 0 C = 2 -2 D = 0
Conversion from pid or pidstd objects is performed the same way. Conversion to pid or pidstd objects is possible only if the system to be converted has the structure of a P, PI, PD, or PID controller, with or without filter on the derivative term.
Conversion to an frd object requires an array of frequency points where the frequency response is evaluated. Conversion of frd objects to other LTI objects is not possible.
Conversion between continuous-time and discrete-time objects of the same class is performed with c2d and d2c.
Simple systems can be combined to create larger ones. All systems can be seen as matrices mapping inputs to outputs via a matrix product. Larger systems can be created by matrix concatenation, addition or multiplication. More specialized connections can be obtained with methods connect and feedback.
Mixing objects of different classes is possible for all classes except for frd (where a frequency array must be provided explicitly, which can only be done with a call of the frd constructor). Continuous-time objects cannot be connected with discrete-time objects, and discrete-time objects must have the same sampling period.
LTI frequency response data constructor.
use lti a = frd a = frd(resp, freq) a = frd(resp, freq, Ts)
frd(response,frequency,Ts) creates an LTI object which represents a discrete set of frequency response data. Argument response is an array of complex frequency responses corresping to frequency array freq.
A single-input single-output (SISO) PID controller has scalar parameters. If the parameters are matrices, they must all have the same size (scalar values are replicated as required), and the resulting controller has as many inputs as parameters have columns and as many outputs as parameters have rows; mapping from each input to each output is and independent SISO PID controller.
Simple continuous-time frd object:
use lti freq = 0:100; resp = 3 ./ (1 + 0.1 * freq * 1j) + 0.1 * randn(size(freq)); r = frd(resp, freq) r = continuous-time frequency response, units=rad/s 1 input, 1 output 101 frequencies
Conversion from a transfer function object:
freq = 0:100; G = tf(1, [1, 2, 3, 4]); r = frd(G, freq) r = continuous-time frequency response, units=rad/s 1 input, 1 output 101 frequencies
LTI PID controller constructor.
use lti a = pid a = pid(Kp, Ki, Kd, Tf) a = pid(Kp, Ki, Kd, Tf, Ts) a = pid(Kp, Ki, Kd, Tf, Ts, var) a = pid(..., IFormula=f1, DFormula=f2)
pid(Kp, Ki, Kd, Tf) creates an LTI object which represents the
continuous-time PID controller
A single-input single-output (SISO) PID controller has scalar parameters. If the parameters are matrices, they must all have the same size (scalar values are replicated as required), and the resulting controller has as many inputs as parameters have columns and as many outputs as parameters have rows; mapping from each input to each output is an independent SISO PID controller.
pid(Kp, Ki, Kd, Tf, Ts) creates an LTI object which represents
the discrete-time PID controller
Name | Value |
---|---|
'ForwardEuler' | |
'BackwardEuler' | |
'Trapezoidal' |
The default formula for both the integral and the derivative terms is 'ForwardEuler'.
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' for forward time shift, 'z^-1' or 'q^-1' for backward time shift).
For PID controllers based on the standard parameters Kp, Ti and Td, where Ki=Kp/Ti and Kd=Kp*Td, pidstd objects should be used instead.
Simple continuous-time PID controller:
use lti C = pid(5,2,1) C = continuous-time PID controller Kp + Ki/s + Kd s/(Tf s + 1) Kp = 5 Ki = 2 Kd = 1 Tf = 0
Discrete-time PD controller where the derivative term, filtered with a time constant of 20ms, is approximated with the Backward Euler formula, with a sampling period of 1ms. The controller is displayed with the backward-shift operator q^-1.
C = pid(5,0,1,20e-3,1e-3,'q^-1',DFormula='BackwardEuler') C = discrete-time PD controller, Ts=1e-3 Kp + Kd/(Tf + Id(q^-1)) Id(q^-1) = Ts/(1-q^-1) (BackwardEuler) Kp = 5 Kd = 1 Tf = 2e-2
Conversion of a first-order continuous-time transfer function with pole at 0 (integrator effect) to a continuous-time PI controller:
G = tf([1, 2], [1, 0]) G = continuous-time transfer function (s+2)/s C = pid(G) C = continuous-time PI controller Kp + Ki/s Kp = 1 Ki = 2
Conversion of a discrete-time PID controller with the Backward Euler formula for the integral term and the Trapezoidal formula for the derivative term to a transfer function, and back to a PID controller:
C1 = pid(5, 2, 3, 0.1, 0.01, IFormula='BackwardEuler', DFormula='Trapezoidal') C1 = discrete-time PID controller, Ts=1e-2 Kp + Ki Ii(z) + Kd/(Tf + Id(z)) Ii(z) = Ts z/(z-1) (BackwardEuler) Id(z) = Ts/2 (z+1)/(z-1) (Trapezoidal) Kp = 5 Ki = 2 Kd = 3 Tf = 0.1 G = tf(C1) G = discrete-time transfer function, Ts=1e-2 (3.5271z^2-7.0019z+3.475)/(0.105z^2-0.2z+9.5e-2) C2 = pid(G, IFormula='BackwardEuler', DFormula='Trapezoidal') C2 = discrete-time PID controller, Ts=1e-2 Kp + Ki Ii(z) + Kd/(Tf + Id(z)) Ii(z) = Ts z/(z-1) (BackwardEuler) Id(z) = Ts/2 (z+1)/(z-1) (Trapezoidal) Kp = 5 Ki = 2 Kd = 3 Tf = 10e-2
LTI standard PID controller constructor.
use lti a = pidstd a = pidstd(Kp, Ti, Td, N) a = pidstd(Kp, Ti, Td, N, Ts) a = pidstd(Kp, Ti, Td, N, Ts, var) a = pidstd(..., IFormula=f1, DFormula=f2)
pidstd(Kp,Ti,Td,N) creates an LTI object which represents the
standard continuous-time PID controller
A single-input single-output (SISO) PID controller has scalar parameters. If the parameters are matrices, they must all have the same size (scalar values are replicated as required), and the resulting controller has as many inputs as parameters have columns and as many outputs as parameters have rows; mapping from each input to each output is and independent SISO PID controller.
pid(Kp,Ti,Td,N,Ts) creates an LTI object which represents
the standard discrete-time PID controller
Name | Value |
---|---|
'ForwardEuler' | |
'BackwardEuler' | |
'Trapezoidal' |
The default formula for both the integral and the derivative terms is 'ForwardEuler'.
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' for forward time shift, 'z^-1' or 'q^-1' for backward time shift).
For PID controllers based on the gain parameters Kp, Ki=Kp/Ti, Kd=Kp*Td, and Tf=Td/N, pid objects should be used instead. Class pidstd is a subclass of pid. The only differences are the arguments of their constructors and the way their objects are displayed by char, disp and mathml.
Simple standard continuous-time PID controller:
use lti C = pidstd(5,4,1) C = continuous-time PID controller Kp (1 + 1/(Ti s) + Td s/(Td/N s + 1)) Kp = 5 Ti = 4 Td = 1 N = inf
Conversion to a pid object:
C1 = pid(C) C1 = continuous-time PID controller Kp + Ki/s + Kd s/(Tf s + 1) Kp = 5 Ki = 1.25 Kd = 5 Tf = 0
Standard discrete-time PD controller where the derivative term, filtered with a time constant 20 times smaller than the derivator time, is approximated with the Backward Euler formula, with a sampling period of 1ms. The controller is displayed with the backward-shift operator q^-1.
C = pidstd(5,0,1,20,1e-3,'q^-1',DFormula='BackwardEuler') C = discrete-time PID controller, Ts=1e-3 Kp (1 + Ii(q^-1)/Ti + Td/(Td/N + Id(q^-1))) Ii(q^-1) = Ts q^-1/(1-q^-1) (ForwardEuler) Id(q^-1) = Ts/(1-q^-1) (BackwardEuler) Kp = 5 Ti = 0 Td = 1 N = 20
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 can 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)
zpk::zpk, pid::pid, pidstd::pidstd, ss::ss
LTI zero-pole-gain constructor.
use lti a = zpk(z, p, k) a = zpk(Z, P, K) a = zpk(..., Ts) a = zpk(..., Ts, var) a = zpk(..., b) a = zpk(b)
zpk creates a zero-pole-gain LTI object. It accepts a vector of zeros, a vector of poles, and a scalar gain for a simple-input simple-output (SISO) system; or a cell array of zeros, a cell array of poles, and a real array of gains for multiple-input multiple-output (MIMO) systems. zpk(z,p,k,Ts) creates an LTI object which represents a discrete-time transfer function with sampling period Ts.
In both cases, z and p can be replaced with cell arrays of coefficients whose elements are the zeros and poles vectors, and k with a matrix of the same size. 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').
zpk(...,b), where b is an LTI object, creates a zero-pole-gain transfer function of the same kind (continuous/discrete time, sampling time and variable) as b.
zpk(b) converts the LTI object b to a zero-pole-gain transfer function.
use lti sd = zpk(0.3, [0.8+0.5j; 0.8-0.5j], 10, 0.1) discrete-time zero-pole-gain transfer function, Ts=0.1 10(z-0.3)/(z-(0.8+0.5j)(z-(0.8-0.5j)
tf::tf, pid::pid, pidstd::pidstd, ss::ss
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 for classes ss, tf and zpk, and 'ForwardEuler', 'BackwardEuler' or 'Trapezoidal' for classes pid and pidstd.
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.
Conjugate transpose.
use lti b = a' b = ctranspose(a)
a' or ctranspose(a) gives the conjugate transpose of a.
The conjugate of the single-input single-output (SISO) continuous-time transfer function G(s) is defined as G(-s), and the conjugate of the SISO discrete-time transfer function G(z) is defined as G(1/z); the conjugate transpose is the conjugate of the transpose of the original system.
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.
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 for classes ss, tf and zpk, and is ignored for class pid and pidstd.
Steady-state gain.
use lti g = dcgain(a)
dcgain(a) gives the steady-state gain of system a.
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
Frequency concatenation.
use lti c = fcat(a, b)
fcat(a,b) concatenates the frequency response data of frd objects a and b along the frequency axis, and sort data by increasing frequency. The size of a and b must be the same (same numbers of inputs and outputs).
use lti G = tf(1, [1, 2, 3, 4]); a = frd(G, 0:5); b = frd(G, 6:20); c = fcat(a, b); d = frd(G, 0:20); // same as c
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.
Get frequency response data.
use lti (resp, freq) = frdata(f) (resp, freq, Ts) = frdata(f)
frdata(f), where f is an frd object, gives the complex frequency response, the corresponding frequencies, and optionally the sampling period or the empty array [] for continuous-time systems.
Frequency selection.
use lti b = fselect(a, ix) b = fselect(a, sel) b = fselect(a, freqmin, freqmax)
fselect(a,ix) selects frequencies of frd object a whose index are in array ix. The frequencies of the result are a.freq(ix).
fselect(a,sel) selects frequencies of frd object a corresponding to true values in logical array sel. The frequencies of the result are a.freq(sel).
fselect(a,freqmin,freqmax) selects frequencies of frd object a which are greater than or equal to freqmin and less than or equal to freqmax. The frequencies of the result are a.freq(a.freq>=freqmin&a.freq<=freqmax).
Frequency interpolation.
use lti b = interp(a, freq) b = interp(a, freq, method)
interp(a,freq) interpolates response data of frd object a at the frequencies in array freq. The frequencies of the result are freq. The interpolation method is linear. Interpolation for frequencies outside the frequency range of a yields nan (not a number).
interp(a,freq,method) use the specified method for interpolation. Method is one of the strings accepted by interp1 ('0' or 'nearest', '<', '>', '1' or 'linear', '3' or 'cubic', 'p' or 'pchip').
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.
Conversion to MathML.
use lti, lti_mathml str = mathml(G) str = mathml(G, false) str = mathml(..., Format=f, NPrec=n)
mathml(x) converts its argument x to MathML presentation, returned as a string.
By default, the MathML top-level element is <math>. If the result is to be used as a MathML subelement of a larger equation, a last input argument equal to the logical value false can be specified to suppress <math>.
By default, mathml converts numbers like format '%g' of sprintf. Named arguments can override them: format is a single letter format recognized by sprintf and NPrec is the precision (number of decimals).
use lti, lti_mathml G = zpk(-1, [1, 2+j, 2-j], 2); m = mathml(G); math(0, 0, m);
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.
Get PID parameters.
use lti (Kp, Ki, Kd, Tf) = piddata(a) (Kp, Ki, Kd, Tf, Ts) = piddata(a)
piddata(a), where a is any kind of LTI object which has the structure of a PID controller except for frd, gives the PID parameters Kp, Ki, Kd and Tf, and optionally the sampling period or the empty array [] for continuous-time systems. The parameters are given as matrices; the rows correspond to the outputs, and their columns to the inputs.
pid::pid, lti::pidstddata, lti::tfdata
Get standard PID parameters.
use lti (Kp, Ti, Td, N) = pidstddata(a) (Kp, Ti, Td, N, Ts) = pidstddata(a)
pidstddata(a), where a is any kind of LTI object which has the structure of a PID controller except for frd, gives the standard PID parameters Kp, Ti, Td and N, and optionally the sampling period or the empty array [] for continuous-time systems. The parameters are given as matrices; the rows correspond to the outputs, and their columns to the inputs.
pidstd::pidstd, lti::piddata, lti::tfdata
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.
Replicate a system.
use lti b = repmat(a, n) b = repmat(a, [m,n]) b = repmat(a, m, n)
repmat(a,m,n), when a is an lti object and m and n are positive integers, creates a new system of the same class with m times as many outputs and n times as many inputs. If a is a matrix of transfer functions, it is replicated m times vertically and n horizontally, as if a were a numeric matrix. If a is a state-space system, matrices B, C, and D are replicated to obtain the same effect.
repmat(a,[m,n]) gives the same result as repmat(a,m,n); repmat(a,n) gives the same result as repmat(a,n,n).
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.
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 except for frd, 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 zero-pole-gain transfer functions, z and p (cell arrays of zero or pole vectors), and k (gain matrix); for PID controllers, Kp, Ki, Kd, Tf, Ti and Td (controller parameter matrices); for all LTI objects, 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, with the same state vector (the same matrix A) as the original system. 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.
If the variable is an frd object, var('freq',i) produces a new frd object where the frequency vector is var.frequency(i) amd the response array contains the corresponding reponse. i can be a scalar index, a vector of indices or a logical array with the same size as var.frequency.
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 zero-pole-gain transfer functions, z and p (cell arrays of zero or pole vectors), and k (gain matrix); for PID controllers, Kp, Ki, Kd, Tf, Ti and Td (controller parameter matrices); for all LTI objects, 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) = tfdata(a)
tfdata(a), where a is any kind of LTI object except for frd, 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 correspond to the outputs, and their columns to the inputs.
tf::tf, lti::zpkdata, lti::ssdata
Transpose.
use lti b = a.' b = transpose(a)
a.' or transpose(a) gives the transpose of a, i.e. a.'(i,j)=a(j,i).
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.
Positive.
use lti b = +a b = uplus(a)
+a gives a.
Get zeros, poles and gains.
use lti (z, p, k) = zpkdata(a) (z, p, k, Ts) = zpkdata(a)
zpkdata(a), where a is any kind of LTI object except for frd, gives the zeros, poles and gains of the transfer function model, and optionally the sampling period or the empty array [] for continuous-time systems. The zeros and poles are given as a cell array of vectors; the rows of the cell arrays correspond to the outputs, and their columns to the inputs.