## Mixed-Sensitivity Loop Shaping

Mixed-sensitivity loop shaping lets you design an H controller by simultaneously shaping the frequency responses for tracking and disturbance rejection, noise reduction and robustness, and controller effort. This technique is a useful way to balance the necessary tradeoff between performance and robustness. To use this technique, you convert your desired responses into up to three weighting functions that the `mixsyn` command uses to synthesize the controller.

### Problem Setup

`mixsyn` designs a controller K for your plant G, assuming the standard control configuration of the following diagram. To do so, the function appends the weighting functions you provide, W1(s), W2(s), and W3(s), to the control system, as shown in the following diagram. `mixsyn` treats the problem as an H synthesis problem (see `hinfsyn`). It analyzes the weighted control system as LFT(P,K), where P is an augmented plant P such that {z;e} = P{w;u}, as shown in the following diagram. The transfer function from w to z can be expressed as

`$M\left(s\right)=\left[\begin{array}{c}{W}_{1}S\\ {W}_{2}KS\\ {W}_{3}T\end{array}\right],$`

where

• S = (I + GK)–1 is the sensitivity function.

• KS is the transfer function from w to u (the control effort).

• T = (IS) = GK(I + GK)–1 is the complementary sensitivity function.

`mixsyn` seeks a controller K that minimizes ||M(s)||, the H norm (peak gain) of M. To do so, it invokes `hinfsyn` on the augmented plant ```P = augw(G,W1,W2,W3)```.

### Choose Weighting Functions

For loop gain L = GK, to achieve good reference tracking and disturbance rejection, you typically want high loop gain at low frequency. To achieve robustness and attenuation of measurement noise, you typically want L to roll off at high frequency. This loop shape is equivalent to small S at low frequency and small T at high frequency.

For mixed-sensitivity loop shaping, you choose weighting functions to specify those target shapes for S and T as well as the control effort KS. The H design constraint,

`${‖M\left(s\right)‖}_{\infty }={‖\left[\begin{array}{c}{W}_{1}S\\ {W}_{2}KS\\ {W}_{3}T\end{array}\right]‖}_{\infty }\le \text{\hspace{0.17em}}\text{\hspace{0.17em}}1,$`

means that

`$\begin{array}{c}{‖S‖}_{\infty }\le |{W}_{1}^{-1}|\\ {‖KS‖}_{\infty }\le |{W}_{2}^{-1}|\\ {‖T‖}_{\infty }\le |{W}_{3}^{-1}|.\end{array}$`

Therefore, you set the weights equal to the reciprocals of the desired shapes for S, KS, and T. In particular,

• For good reference-tracking and disturbance-rejection performance, choose W1 large inside the control bandwidth to obtain small S.

• For robustness and noise attenuation, choose W3 large outside the control bandwidth to obtain small T.

• To limit control effort in a particular frequency band, increase the magnitude of W2 in this frequency band to obtain small KS.

`mixsyn` returns the minimum ||M(s)|| in the output argument `gamma`. For the returned controller K, then,

`$\begin{array}{c}{‖S‖}_{\infty }\le \gamma |{W}_{1}^{-1}|\\ {‖KS‖}_{\infty }\le \gamma |{W}_{2}^{-1}|\\ {‖T‖}_{\infty }\le \gamma |{W}_{3}^{-1}|.\end{array}$`

If you do not want to restrict control effort, you can omit W2. In that case, `mixsyn` minimizes the H norm of

`$M\left(s\right)=\left[\begin{array}{c}{W}_{1}S\\ {W}_{3}T\end{array}\right].$`

You can use `makeweight` to create weighting functions with the desired gain profiles. The following example illustrates how to choose and create weighting functions for controller design with `mixsyn`.

#### Numeric Considerations

Do not choose weighting functions with poles very close to s = 0 (z = 1 for discrete-time systems). For instance, although it might seem sensible to choose W1 = 1/s to enforce zero steady-state error, doing so introduces an unstable pole that cannot be stabilized, causing synthesis to fail. Instead, choose W1 = 1/(s + δ). The value δ must be small but not very small compared to system dynamics. For instance, for best numeric results, if your target crossover frequency is around 1 rad/s, choose δ = 0.0001 or 0.001. Similarly, in discrete time, choose sample times such that system and weighting dynamics are not more than a decade or two below the Nyquist frequency.

### Mixed-Sensitivity Loop-Shaping Controller Design

Load a plant model for a mixed-sensitivity${\mathit{H}}_{\infty }$ controller design. This two-input, two-output, six-state model is described in the example Loop Shaping of HIMAT Pitch Axis Controller.

```load mixsynExampleData G size(G)```
```State-space model with 2 outputs, 2 inputs, and 6 states. ```

To design a controller for performance and robustness, shape the sensitivity and complementary sensitivity functions. Choose weights that are the inverse of the desired shapes.

To achieve good reference-tracking and disturbance-rejection performance, shape S to be small inside the control bandwidth, which means choosing `W1` large at low frequency, rolling off at high frequency. For this example, specify `W1` with:

• Low-frequency gain of about 30 dB (33 in absolute units)

• High-frequency gain of about –6 dB (0.5 in absolute units)

`W1 = makeweight(33,5,0.5);`

For robustness and noise attenuation, shape `T` to be small outside the control bandwidth, which means choosing `W3` large at high frequency.

`W3 = makeweight(0.5,20,20);`

Examine both weighting functions. Their inverses are the target shapes for `S` and `T`.

```bodemag(W1,W3) yline(0,'--'); legend('W1','W3','0 dB') grid on``` Because `S + T = I`, `mixsyn` cannot make both `S` and `T` small (less than 0 dB) in the same frequency range. Therefore, when you specify weights, there must be a frequency band in which both `W1` and `W3` are below 0 dB.

Use `mixsyn` to compute the optimal mixed-sensitivity controller with these weights. For this example, impose no penalty on controller effort by setting `W2` to `[]`.

```[K,CL,gamma] = mixsyn(G,W1,[],W3); gamma```
```gamma = 0.7331 ```

The resulting `gamma`, which is the peak singular value across all frequencies, is well below 1, indicating that the closed-loop system meets the design requirements. Examine the resulting system responses. First, compare the resulting sensitivity `S` and complementary sensitivity `T` to the corresponding weighting functions `W1` and `W3`.

```L = G*K; I = eye(size(L)); S = feedback(I,L); T= I-S; sigma(S,'b',W1,'b--',T,'r',W3,'r--',{0.1,1000}) legend('S','W1','T','W3')``` The plot shows that `S` and `T` achieve the desired loop shape, where `S` is large inside the control bandwidth and a is small outside the control bandwidth.

To see how mixed-sensitivity loop-shaping achieves the goals of classic loop shaping, compare the open-loop response `L` to the weighting functions. `L ~ W1` where `W1` is large, and `L ~ 1/W3` where `W3` is large.

```sigma(L,'b',W1,'r--',1/W3,'g--',{0.1,1000}) legend('L','W1','1/W3')```  