
% ExplX3_1.m :  
% Exact frequency response and RGA of MIMO plant with time delay

% This is 3x3 plant where each element is on the form (k, tau, theta)
% where k is the gain, tau the time constant and theta the delay.

% For the numbers used in this example see process T4 of Luyben, 
% which is used as Example 3 by Huang et al. (J.Proc.Control, 15-27, 1994).

% We here want to use the RGA to check which pairing is best.
% So we only need the frequency response, and we use function fod_f.m.
% If we wanted a state-space desciption then we would need a Pade-
% approximation of the delay; see function fod.m

% omega = logspace(-3,1,161);
g11 = fod_f(-1.986, 66.67, 0.71, omega);
g12 = fod_f(5.24,400,60, omega);
g13 = fod_f(5.984,14.29,2.24, omega);
g21 = fod_f(0.0204, 5, 4.199, omega);
g22 = fod_f(-0.33, 3.904, 1.883, omega);
g23 = fod_f(2.38, 10, 1.143, omega);
g31 = fod_f(0.374, 22.22, 7.75, omega);
g32 = fod_f(-11.3, 35.66, 14.78, omega);
g33 = fod_f(-9.881, 11.35, 1.59, omega);

G  = sbs(sbs( abv(g11,g21,g31) , abv(g12,g22,g32) ),abv(g13,g23,g33));

Grga = vrga(G);
vplot('liv,lm',Grga);

% Pairing no. 1: Pair on diagonal elements:
i1 = [1 0 0; 0 1 0; 0 0 1];
% Compute (almost) the RGA-number, , see (3.71), but we use singular value;
vplot('liv,m',vnorm(msub(Grga,i1))); % peaks of 10 for w > 0.7 rad/s
% But really frequncies larger than about 0.1 rad/s are of minor importance

% Do same for pairing alternative no. 2:
i2 = [1 0 0; 0 0 1; 0 1 0];
vplot('liv,m',vnorm(msub(Grga,i2)));

% Conclusion: The last pairing best (consider frequencies up to 0.5 rad/s)


