| Control System Toolbox™ | ![]() |
| On this page… |
|---|
Building LTI Arrays Using for Loops Building LTI Arrays Using the stack Function |
There are several ways to build LTI arrays:
Using a for loop to assign each model in the array
Using stack to concatenate LTI models into an LTI array
Using tf, zpk, ss, or frd
In addition, you can use the command rss to generate LTI arrays of random state-space models.
Consider the following second-order SISO transfer function that
depends on two parameters,
and
![]()
![]()
Suppose, based on measured input and output data, you estimate
confidence intervals
, and
for each of the parameters,
and
. All of the possible combinations of the confidence limits for these
model parameter values give rise to a set of four SISO models.
Four LTI Models Depending on Two Parameters

You can arrange these four models in a 2-by-2 array of SISO transfer functions called H.
The LTI Array H

Here, for
,
represents the transfer function

corresponding to the parameter values
and
.
The first two colon indices (
) select all
I/O channels from the I/O dimensions of H. The
third index of H refers to the first array dimension
(
), while the fourth
index is for the second array dimension (
).
Suppose the limits of the ranges of values for
and
are [0.66,0.76] and [1.2,1.5],
respectively. Enter these at the command line.
zeta = [0.66,0.75]; w = [1.2,1.5];
Since the four models have the same parametric structure, it's convenient to use two nested for loops to construct the LTI array.
for i = 1:2
for j = 1:2
H(:,:,i,j) = tf(w(j)^2,[1 2*zeta(i)*w(j) w(j)^2]);
end
end
H now contains the four models in a 2-by-2 array. For example, to display the transfer function in the (1,2) position of the array, type
H(:,:,1,2)
Transfer function:
2.25
-------------------
s^2 + 1.98 s + 2.25
For the purposes of efficient computation, you can initialize an LTI array to zero, and then reassign the entire array to the values you want to specify. The general syntax for zero assignment of LTI arrays is

To initialize H in the above example to zero, type
H = tf(zeros(1,1,2,2));
before you implement the nested for loops.
Another way to build LTI arrays is using the function stack. This function operates on single LTI models as well as LTI arrays. It concatenates a list of LTI arrays or single LTI models only along the array dimension. The general syntax for stack is
stack(Arraydim,sys1,sys2...)
where
Arraydim is the array dimension along which to concatenate the LTI models or arrays.
sys1, sys2, ... are the LTI models or LTI arrays to be concatenated.
When you concatenate several models or LTI arrays along the jth array dimension, such as in
stack(j,sys1,sys2,...,sysn)
The lengths of the I/O dimensions of sys1,...,sysn must all match.
The lengths of all but the jth array dimension of sys1,...,sysn must match.
For example, if two TF models sys1 and sys2 have the same number of inputs and outputs,
sys = stack(1,sys1,sys2)
concatenates them into a 2-by-1 array of models.
There are two principles that you should keep in mind:
stack only concatenates along an array dimension, not an I/O dimension.
To concatenate LTI models or LTI arrays along an input or output dimension, use the bracket notation ([,] [;]). See Model Interconnection Functions for more information on the use of bracket notation to concatenate models. See also Special Cases for Operations on LTI Arrays for some examples of this type of concatenation of LTI arrays.
Here's an example of how to build the LTI array H using the function stack.
% Set up the parameter vectors. zeta = [0.66,0.75]; w = [1.2,1.5]; % Specify the four individual models with those parameters. % H11 = tf(w(1)^2,[1 2*zeta(1)*w(1) w(1)^2]); H12 = tf(w(2)^2,[1 2*zeta(1)*w(2) w(2)^2]); H21 = tf(w(1)^2,[1 2*zeta(2)*w(1) w(1)^2]); H22 = tf(w(2)^2,[1 2*zeta(2)*w(2) w(2)^2]); % Set up the LTI array using stack. COL1 = stack(1,H11,H21); % The first column of the 2-by-2 array COL2 = stack(1,H12,H22); % The second column of the 2-by-2 array H = stack(2, COL1, COL2); % Concatenate the two columns of models.
Notice that this result is very different from the single MIMO LTI model returned by
H = [H11,H12;H21,H22];
For arrays of state-space models with variable order, you cannot use the dot operator (e.g., sys.a) to access arrays. Use the syntax
[a,b,c,d] = ssdata(sys,'cell')
to extract the state-space matrices of each model as separate cells in the cell arrays a, b, c, and d.
You can also build LTI arrays using the tf, zpk, ss, and frd constructors. You do this by using multidimensional arrays in the input arguments for these functions.
For TF models, use
sys = tf(num,den)
where
Both num and den are multidimensional cell arrays the same size as sys (see Accessing the Dimensions of an LTI Array Using size and ndims).
sys(i,j,n1,...,nK) is the (i, j) entry of the transfer matrix for the model located in the
position of the array.
num(i,j,n1,...,nK) is a row vector representing the numerator polynomial of sys(i,j,n1,...,nK).
den(i,j,n1,...,nK) is a row vector representing denominator polynomial of sys(i,j,n1,...,nK).
See MIMO Transfer Function Models for related information on the specification of single TF models.
For ZPK models, use
sys = zpk(zeros,poles,gains)
where
Both zeros and poles are multidimensional cell arrays whose cell entries contain the vectors of zeros and poles for each I/O pair of each model in the LTI array.
gains is a multidimensional array containing the scalar gains for each I/O pair of each model in the array.
The dimensions (and their lengths) of zeros, poles, and gains, determine those of the LTI array, sys.
To specify arrays of SS models, use
sys = ss(a,b,c,d)
where a, b, c, and d are real- or complex-valued multidimensional arrays of appropriate dimensions. All models in the resulting array of SS models have the same number of states, outputs, and inputs.
Note You cannot use the ss constructor to build an array of state-space models with different numbers of states. Use stack to build such LTI arrays. |
The size of the model data for arrays of state-space models is summarized in the following table.
Data | Size (Data) |
|---|---|
a |
|
b |
|
c |
|
d |
|
where
is the maximum of
the number of states in each model in the array.
is the number of
inputs in each model.
is the number of
outputs in each model.
are the lengths of
the array dimensions.
To specify a K-dimensional array of p-output, m-input FRD models for
which
are the lengths of
the array dimensions, use
sys = frd(response,frequency,units)
where
frequency is a real vector of n frequency data points common to all FRD models in the LTI array.
response is a p-by-m-by-n-by-
-by-
-by-
complex-valued multidimensional array.
units is the optional string specifying 'rad/s' or 'Hz'.
Note that for specifying an LTI array of SISO FRD models, response can also be a multidimensional array of 1-by-n matrices whose remaining dimensions determine the array dimensions of the FRD.
A convenient way to generate arrays of state-space models with the same number of states in each model is to use rss. The syntax is
rss(N,P,M,sdim1,...,sdimk)
where
N is the number of states of each model in the LTI array.
P is the number of outputs of each model in the LTI array.
M is the number of inputs of each model in the LTI array.
sdim1,...,sdimk are the lengths of the array dimensions.
For example, to create a 4-by-2 array of random state-space models with three states, one output, and one input, type
sys = rss(3,2,1,4,2); size(sys) 4x2 array of continuous-time state-space models Each model has 2 outputs, 1 input, and 3 states.
![]() | Dimensions, Size, and Shape of an LTI Array | Indexing into LTI Arrays | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |