# Documentation

## Approximate Model with Lower-Order Model

This example shows how to compute a reduced-order approximation of a model using `balred`.

To compute a reduced-order approximation, you first choose an order for the reduced model by examining the contribution of the various states to the overall model behavior.

```load ltiexamples hplant order(hplant) ```
```ans = 23 ```

`hplant` is a 23rd-order SISO model. When choosing an order for the reduced system, it is helpful to know how many states make a significant contribution to the overall model behavior.

Examine the relative amount of energy per state using a Hankel singular value (HSV) plot.

```hsvplot(hplant) ```

Small Hankel singular values indicate that the associated states contribute little to the behavior of the system. The plot shows that two states account for most of the energy in the system. Therefore, try simplifying the model to just first or second order.

Compute first-order and second-order reduced approximations of `hplant`.

```opts = balredOptions('StateElimMethod','Truncate'); hplant1 = balred(hplant,1,opts); hplant2 = balred(hplant,2,opts); ```

The second argument to `balred` specifies the target approximation order.

By default, `balred` discards the states with the smallest Hankel singular values, and alters the remaining states to preserve the DC gain of the system. Setting the `StateElimMethod` option to `Truncate` causes `balred` to discard low-energy states without altering the remaining states.

Compare the frequency responses of the original and approximated systems.

When working with reduced-order models, it is important to verify that the approximation does not introduce inaccuracies at frequencies that are important for your application.

```bodeplot(hplant,hplant2,hplant1) legend('Original','2nd order','1st order') ```

When working with MIMO systems, you can use `sigma` to examine a singular value plot rather than a Bode plot.

In this case, the second-order system matches the original 23rd-order system very well, especially at lower frequencies. The first-order system does not match as well.

In general, as you decrease the order of the approximated model, the frequency response of the approximated model begins to differ from the original model. Choose an approximation that is sufficiently accurate in the bands that are important to you. For example, in a control system, you might want good accuracy inside the control bandwidth. Accuracy at frequencies far above the control bandwidth, where the gain rapidly rolls off, might be less important.

Examine the time-domain responses of the original and reduced-order systems.

```stepplot(hplant,hplant2,hplant1) legend('Original','2nd order','1st order','Location','SouthEast') ```

This result confirms that the second-order approximation is a good match to the original 23rd-order system.