It frequently happens that one would like to implement control-switching schemes to facilitate changing modes, where different controller are subsequently active with the aim to achieve different objectives. Many of such control implementations can be subsumed as shown in the following interconnection.

Here is the plant to be controlled, while , , represents the control switching scheme (i.e. for controller is active, while for controller is active). Here is a time-varying parameter that in practice is often switched from 0 to 1 in an instantaneous manner. In other more careful implementations, the parameter is slowly varied for 0 to 1 to facilitate a smoother transitioning between the different controllers.

There are a few issues with this approach:

- An instantaneous switch may cause significant disruptions in the closed loop system. The effect is similar to recovering from a nonzero initial condition.
- For smoother implementations, where is varied slowly from 0 to 1, it is unknown if the closed loop system is guaranteed to be stable. This is certainly a problem if either one of the controllers is unstable.

**A Youla based solution**

To resolve the latter issues, one can proceed according to the approach suggested in [11], [12]. This proceeds as follows.

Let be a proper LTI system that admits the realization

where the pairs and are stabilizable and detectable respectively. Then one can compute the coprime factors , which satisfy the Bezout identity

where all eight transfer matrices are in .

This can be done using the function *fCoprime* (details). Given and the eight transfer matrices that satisfy the Bezout identity, one then can arrive at an entire family of controllers that internally stabilize .

This parameterization is given by

where can be any transfer matrix in . This transfer matrix is the celebrated Youla parameter.

Note that can also be written as a lower LFT of some fixed transfer matrix and the Youla parameter :

For a given controller that internally stabilizes , even if is unstable, it is possible to obtain an interconnection by considering the coprime factors of . Then the Youla parameter can be taken to be

To continue, let us be given two controllers and . Then one can obtain the Youla parameters and as sketched above. This leads to the Youla based control-switching scheme depicted in the following figure with:

When is fixed for all , the Youla parameter is stable, which also implies that the control interconnection of the latter figure is stable. Hence, for any trajectory during the switching phase, the resulting controller can be regarded as a linear time varying system. In [11] it is shown that also for this case, the closed-loop system will remain stable.

Note in case is already stable, i.e., , then the matrices in the Bezout identity may be taken as:

- ,

In this case, we obtain with the Youla parameter .

**Implementation**

The function implements the described procedure. Here:

- is the part of the plant seen by the controller. This realization must be stabilizable and detectable.
- The controllers , , which both stabilize .

As output this yields:

- The transfer matrix with realization
- The structure with the Youla parameters .

These can be interconnected as in accordance with the figure above, or, in case of more than two controllers as with .

*Note: The algorithms works for continuous- as well as discrete-time systems.*

**Demonstrating example**

A demonstration of this procedure is found here.