Accelerating the pace of engineering and science

# Documentation

## MIMO Model Creation

How to create multi-input, multi-output (MIMO) models.

### MIMO Transfer Function Model

This example shows how to create a multi-input, multi-output (MIMO) transfer function model by concatenating single-input, single-output (SISO) transfer function models.

To create the one-input, two-output MIMO transfer function:

$G\left(s\right)=\left[\begin{array}{c}\frac{s-1}{s+1}\\ \frac{s+2}{{s}^{2}+4s+5}\end{array}\right],$

perform the following steps:

1. Create SISO transfer functions for each channel.

```g11 = tf([1 -1],[1 1]);
g21 = tf([1 2],[1 4 5]);
```
 Tip   Use zpk instead of tf to create MIMO transfer functions in factorized form.
2. Concatenate the transfer functions.

`G = [g11; g21];   `

### MIMO State-Space Model

This example shows how to create a MIMO state-space model using ss.

You create a MIMO state-space model in the same way as you create a SISO state-space model. The only difference between the SISO and MIMO cases is the dimensions of the state-space matrices. The dimensions of the B, C, and D matrices increase with the numbers of inputs and outputs as shown in the following illustration.

In this example, you create a state-space model for a rotating body with inertia tensor J, damping force F, and three axes of rotation, related as:

$\begin{array}{c}J\frac{d\omega }{dt}+F\omega =T\\ y=\omega .\end{array}$

The system input T is the driving torque. The output y is the vector of angular velocities of the rotating body.

To express this system in state-space form:

rewrite it as:

$\begin{array}{c}\frac{d\omega }{dt}=-{J}^{-1}F\omega +{J}^{-1}T\\ y=\omega .\end{array}$

Then the state-space matrices are:

$A=-{J}^{-1}F,\text{ }B={J}^{-1},\text{ }C=I,\text{ }D=0.$

To create this model, enter the following commands:

```J = [8 -3 -3; -3 8 -3; -3 -3 8];
F = 0.2*eye(3);
A = -J\F;
B = inv(J);
C = eye(3);
D = 0:
sys_mimo = ss(A,B,C,D);```

These commands assume that J is the inertia tensor of a cube rotating about its corner, and the damping force has magnitude 0.2.

sys_mimo is an ss model.

### MIMO Descriptor State-Space Model

This example shows how to create a continuous-time descriptor (implicit) state-space model using dss.

 Note:   This example uses the same rotating-body system shown in MIMO State-Space Model, where you inverted the inertia matrix J to obtain the value of the B matrix. If J is poorly-conditioned for inversion, you can instead use a descriptor (implicit) state-space model.

A descriptor (implicit) state-space model is of the form:

$\begin{array}{c}E\frac{dx}{dt}=Ax+Bu\\ y=Cx+Du\end{array}$

Create a state-space model for a rotating body with inertia tensor J, damping force F, and three axes of rotation, related as:

$\begin{array}{c}J\frac{d\omega }{dt}+F\omega =T\\ y=\omega .\end{array}$

The system input T is the driving torque. The output y is the vector of angular velocities of the rotating body. You can write this system as a descriptor state-space model having the following state-space matrices:

$A=-F,\text{ }B=I,\text{ }C=I,\text{ }D=0,\text{ }E=J.$

To create this system, enter:

```J = [8 -3 -3; -3 8 -3; -3 -3 8];
F = 0.2*eye(3);
A = -F;
B = eye(3);
C = eye(3);
D = 0;
E = J;
sys_mimo = dss(A,B,C,D,E)
```

These commands assume that J is the inertia tensor of a cube rotating about its corner, and the damping force has magnitude 0.2.

sys is an ss model with a nonempty E matrix.

### MIMO Frequency Response Data Model

This example shows how to create a MIMO frequency-response model using frd.

Frequency response data for a MIMO system includes a vector of complex response data for each of the input/output (I/O) pair of the system. Thus, if you measure the frequency response of each I/O pair your system at a set of test frequencies, you can use the data to create a frequency response model:

1. Load frequency response data in AnalyzerDataMIMO.mat.

`load AnalyzerDataMIMO H11 H12 H21 H22 freq`

This command loads the data into the MATLAB® workspace as five column vectors H11, H12, H21, H22, and freq. The vector freq contains 100 test frequencies. The other four vectors contain the corresponding complex-valued frequency response of each I/O pair of a two-input, two-output system.

 Tip   To inspect these variables, enter:`whos H11 H12 H21 H22 freq`
2. Organize the data into a three-dimensional array.

```Hresp = zeros(2,2,length(freq));
Hresp(1,1,:) = H11;
Hresp(1,2,:) = H12;
Hresp(2,1,:) = H21;
Hresp(2,2,:) = H22;
```

The dimensions of Hresp are the number of outputs, number of inputs, and the number of frequencies for which there is response data. Hresp(i,j,:) contains the frequency response from input j to output i.

3. Create a frequency-response model.

`H = frd(Hresp,freq);`

sys is an frd model object, which is a data container for representing frequency response data.

You can use frd models with many frequency-domain analysis commands. For example, visualize the response of this two-input, two-output system using bode.

 Tip   By default, the frd command assumes that the frequencies are in radians/second. To specify different frequency units, use the TimeUnit and FrequencyUnit properties of the frd model object. For example:`sys = frd(Hresp,freq,'TimeUnit','min','FrequencyUnit','rad/TimeUnit') `sets the frequency units to in radians/minute.

### Select Input/Output Pairs in MIMO Models

This example shows how to select the response from the first input to the second output of a MIMO model.

1. Create a two-input, one-output transfer function.

```N = {[1 -1],[1];[1 2],[3 1 4]};
D = [1 1 10];
H = tf(N,D)```
 Note:   For more information about using cell arrays to create MIMO transfer functions, see the tf reference page.
2. Select the response from the second input to the output of H.

To do this, use MATLAB array indexing.

`H12 = H(1,2)`

For any MIMO system H, the index notation H(i,j) selects the response from the jth input to the ith output.

Was this topic helpful?