## Balanced Truncation Model Reduction

Balanced truncation computes a lower-order approximation of your model by neglecting
states that have relatively low effect on the overall model response. Using a
lower-order approximation that preserves the dynamics of interest can simplify analysis
and control design. In the balanced truncation method of model reduction, the software
measures state contributions by Hankel singular values (see `hsvd`

) and discards states with smaller values. You can compute a
reduced-order model by balanced truncation:

At the command line, create a model order reduction task using the

`reducespec`

command with the`"balanced"`

method.In the Model Reducer app, using the

**Balanced Truncation**method.In the Reduce Model Order task in the Live Editor, using the

`Balanced Truncation`

method.

For more general information about model reduction, see Model Reduction Basics.

### Balanced Truncation in the Model Reducer App

Model Reducer provides an interactive tool for performing model reduction and examining and comparing the responses of the original and reduced-order models. To approximate a model by balanced truncation in Model Reducer:

Open the app, and import an LTI model to reduce. For instance, suppose that there is a model named

`build`

in the MATLAB^{®}workspace. The following command opens Model Reducer and imports the model.modelReducer(build)

In the data browser, select the model to reduce. Click

**Balanced Truncation**.In the

**Balanced Truncation**tab, Model Reducer displays a plot of the frequency response of the original model and a reduced version of the model. By default, the frequency response is a Bode plot for SISO models, and a singular-value plot for MIMO models. The app also displays a Hankel singular-value and approximation error plot of the original model.The Hankel singular-value plot shows the relative energy contributions of each state in the system. Model Reducer computes an initial reduced-order model based on these values. The highlighted bar is the lowest-energy state in the initial reduced-order model. Model Reducer discards states that have lower Hankel singular values than the highlighted bar.

Try different reduced-model orders to find the lowest-order model that preserves the dynamics that are important for your application. To specify different orders, either:

Specify model orders explicitly in the

**Reduced orders vector**field. You can enter a single integer or an array of integers, such as`10:14`

or`[4,8,10]`

.Click a bar on the Hankel singular-value plot to specify the lowest-energy state of the reduced-order model. Ctrl-click to specify multiple values.

When you change the specified reduced model order, Model Reducer automatically computes a new reduced-order model. If you specify multiple model orders, Model Reducer computes multiple reduced-order models and displays their responses on the plot.

Optionally, examine the absolute or relative error between the original and reduced-order model, in addition to the frequency response. Select the error-plot type using the buttons on the

**Balanced Truncation**tab.For more information about using the analysis plots, see Visualize Reduced-Order Models in Model Reducer App.

If low-frequency dynamics are not important to your application, you can clear the

**Preserve DC Gain**checkbox in the**Options**dialog. Doing so sometimes yields a better match at higher frequencies between the original and reduced-order models.When you check or clear the

**Preserve DC Gain**checkbox, Model Reducer automatically computes new reduced-order models. For more information about available options, see Specify Options for Balanced Truncation in Model Reducer.Optionally, limit the Hankel singular-value computation to a specific frequency range. Such a limit is useful when the model has modes outside the region of interest to your particular application. When you apply a frequency limit, Model Reducer determines which states to truncate based on their energy contribution within the specified frequency range only. Neglecting energy contributions outside that range can yield an even lower-order approximation that is still adequate for your application.

To limit the singular-value computation, click

**Options**and add a frequency interval. Then, specify the frequency range using the**Lower cutoff**and**Upper cutoff**parameters. Here, the units are`rad/TimeUnit`

, where`TimeUnit`

is the`TimeUnit`

property of the model you are reducing.On the response plot or error plot, you can drag the boundaries of the shaded region or the shaded region itself. Model Reducer analyzes the state contributions within the shaded region only.

When you change or clear the frequency range in options, Model Reducer automatically computes new reduced-order models.

You can choose between absolute and relative errors by selecting the

**Control relative error**checkbox. The absolute error is $${\Vert G-{G}_{r}\Vert}_{\infty}$$ while the relative error is $${\Vert {G}^{-1}\left(G-{G}_{r}\right)\Vert}_{\infty}$$. Relative error gives a better match across frequency while absolute error emphasizes areas with most gain.**Note**Switching between error bound options automatically clears the specified frequency range. To enforce a DC match, check

**Preserve DC Gain**. Note that restricting the frequency range is not supported with relative error control.When you have one or more reduced models that you want to store and analyze further, click

**Save Reduced Model**. The new models appear in the data browser. If you have specified multiple orders, each reduced model appears separately. Model names reflect the reduced model order.After creating reduced models in the data browser, you can continue changing the reduction parameters and create reduced models with different orders for analysis and comparison.

You can now perform further analysis with the reduced model. For example:

Examine other responses of the reduced system, such as the step response or Nichols plot. To do so, use the tools on the

**Plots**tab. See Visualize Reduced-Order Models in Model Reducer App for more information.Export reduced models to the MATLAB workspace for further analysis or control design. On the

**Model Reducer**tab, click**Export**.

#### Generate MATLAB Code for Balanced Truncation

To create a MATLAB script you can use for further model-reduction tasks at the command line,
click **Save Reduced Model**, and select **Generate MATLAB
Script**.

Model Reducer creates a script that uses the `reducespec`

and ```
getrom
(balanced)
```

commands to perform model reduction with the
parameters and options you have set on the **Balanced
Truncation** tab. The script opens in the MATLAB editor.

### Balanced Truncation in Other Environments

Instead of working in the Model Reducer app, you can perform balanced truncation in other environments.

In the Live Editor, use the Reduce Model Order task to interactively perform balanced-truncation model reduction and generate code in your live script. For an example, see Model Reduction in the Live Editor.

At the MATLAB command prompt or in scripts and functions, use the

`reducespec`

command. For examples, see: