Engee documentation
Notebook

Frequency response of MIMO systems

This example shows how the frequency response of a multi-input multiple-output (MIMO) system can be investigated in two ways: by computing the frequency response and by computing singular values.

Before you start, connect the package ControlSystems.jl.

In [ ]:
import Pkg
Pkg.add("ControlSystems")
In [ ]:
using ControlSystems
s = tf('s');

Calculate the frequency response of the MIMO model and analyse the output signal size.

In [ ]:
H = ssrand(2,2,3)
mag, phase, w = bode(H)
Out[0]:
([64.35193014748488 110.66105266914876; 4.517702482503937 8.1126829075723;;; 64.35173123989897 110.66071091235746; 4.517688677427745 8.112658012169764;;; 64.35151642715427 110.66034182782086; 4.5176737684629416 8.112631126067845;;; … ;;; 1.3743210863836728 0.48978319836300016; 0.11048789451967378 0.03695369884433167;;; 1.3743208282278998 0.48978365958105596; 0.11048738601888716 0.03694903132103605;;; 1.3743205891888663 0.48978408664557166; 0.11048691517136995 0.03694470890983952], [179.49447401920028 179.48084163877962; 179.43620199457524 179.44556259487726;;; 179.4746496420569 179.4604826340331; 179.41409233664749 179.42382003546894;;; 179.45404793472662 179.43932533235494; 179.39111572573253 179.401224919673;;; … ;;; -179.96421069383405 -0.06983037265621919; -180.50685638303776 -183.24164437539673;;; -179.9655613080031 -0.06719499468835029; -180.48773063550016 -183.11958354405905;;; -179.96686095174016 -0.06465908605398658; -180.4693264552339 -183.00209954377647], [0.0001, 0.00010392174819219933, 0.00010799729747322885, 0.00011223267953450933, 0.00011663416261521083, 0.00012120826077905968, 0.00012596174355495872, 0.00013090164595568805, 0.0001360352788895144, 0.00014137023998011728  …  707.3624548848775, 735.1034291716219, 763.9323346159553, 793.8918371383827, 825.0262759093753, 857.3817289700206, 891.0060814261498, 925.949096316866, 962.2624882623586, 1000.0])
In [ ]:
size_mag = size(mag)
Out[0]:
(2, 2, 420)

The first and second dimensions of the data set mag are the number of outputs and inputs $H$. The third dimension is the number of points in the frequency vector w (The bode command determines this number automatically if you do not specify a frequency vector). Thus, mag(i,j,:) is the frequency response from the j-th input of $H$ to the i-th output. The phase data array phase has the same shape as mag.

Construct the frequency response of each input/output pair in $H$.

In [ ]:
bodeplot(H, title = ["Input 1" "Input 2" "" "" "" "" "" ""], leg = false)
Out[0]:

bodeplot plots the amplitude and phase of the frequency response of each input-output pair in H. (Since ssrand generates a random state-space model, you may see different characteristics from those shown in the figure). The first column plots the frequency response of the circuits going from the first input signal to the first and second outputs. The second column is similar, but from the second input signal to the two outputs of the system.

Plot the singular values of $H$ as a function of frequency.

In [ ]:
sigmaplot(H)
Out[0]:

The diagram sigmaplot shows the dependence of the singular values of the MIMO system $H$ on frequency. The maximum singular value at a particular frequency is the maximum gain of the system over all linear combinations of input signals at that frequency. The singular values can give a better idea of the overall response, stability and tuning of a MIMO system than a channel-by-channel Bode plot.

Calculate the singular values of $H$ over the range of 0.1 to 10 rad/s.

In [ ]:
ω = collect(1:0.001:10);
sv,w = sigma(H,ω)

display([sv,w])
2-element Vector{Array{Float64}}:
 [5.457212482429304 5.461629817019327 … 1.4747258493327937 1.4747227858945642; 0.5374496365843938 0.5377831833004091 … 0.24287151511445718 0.24284864620972058]
 [1.0, 1.001, 1.002, 1.003, 1.004, 1.005, 1.006, 1.007, 1.008, 1.009  …  9.991, 9.992, 9.993, 9.994, 9.995, 9.996, 9.997, 9.998, 9.999, 10.0]

When you call sigma, the command returns the singular values in the data array sv. The input data from the $\omega$ array tells sigma to compute singular values in the frequency range of 0.1 to 10 rad/s. The function sigma returns these frequencies in a vector w. Each line sv contains singular values $H$ at frequencies w.

Conclusion

With the help of the discussed example, we have learnt how to study the frequency response of a MIMO system.