# modsep

Region-based modal decomposition

## Syntax

```[H,H0] = modsep(G,N,REGIONFCN) MODSEP(G,N,REGIONFCN,PARAM1,...) ```

## Description

`[H,H0] = modsep(G,N,REGIONFCN) `decomposes the LTI model `G` into a sum of `n` simpler models `Hj` with their poles in disjoint regions `Rj `of the complex plane:

`$G\left(s\right)=H0+{\sum }_{j=1}^{N}Hj\left(s\right)$`

`G` can be any LTI model created with `ss`, `tf`, or `zpk`, and `N` is the number of regions used in the decomposition. `modsep` packs the submodels `Hj` into an LTI array `H` and returns the static gain `H0` separately. Use `H(:,:,j)` to retrieve the submodel `Hj(s)`.

To specify the regions of interest, use a function of the form

```IR = REGIONFCN(p) ```

that assigns a region index `IR` between 1 and `N` to a given pole `p`. You can specify this function by its name or as a function handle, and use the syntax `MODSEP(G,N,REGIONFCN,PARAM1,...)` to pass extra input arguments:

```IR = REGIONFCN(p,PARAM1,...) ```

## Examples

To decompose `G` into ```G(z) = H0 + H1(z) + H2(z)``` where `H1` and `H2` have their poles inside and outside the unit disk respectively, use

```[H,H0] = modsep(G,2,@udsep) ```

where the function `udsep` is defined by

```function r = udsep(p) if abs(p)<1, r = 1; % assign r=1 to poles inside unit disk else r = 2; % assign r=2 to poles outside unit disk end ```

To extract `H1(z)` and `H2(z)` from the LTI array `H`, use

```H1 = H(:,:,1); H2 = H(:,:,2); ```