# wenergy

Energy for 1-D wavelet or wavelet packet decomposition

## Syntax

``[Ea,Ed] = wenergy(c,l)``
``E = wenergy(wpt)``

## Description

example

````[Ea,Ed] = wenergy(c,l)` returns, for a 1-D wavelet decomposition, `Ea`, the percentage of energy corresponding to the approximation, and `Ed`, the percentages of energies corresponding to the details. `c` and `l` are outputs of `wavedec`.```
````E = wenergy(wpt)` returns the percentages of energy corresponding to the terminal nodes of the wavelet packet tree `wpt` (see `wptree`, `wpdec`, and `wpdec2`). In this case, `wenergy` is a method of the `wptree` object `wpt`, which overloads the previous `wenergy` function.```

## Examples

collapse all

`load noisbump`

Obtain the 4-level wavelet decomposition of the signal using the `sym4` wavelet.

```wv = "sym4"; [c,l] = wavedec(noisbump,4,wv);```

Obtain the percentages of energy in the approximation and details coefficients.

`[Ea,Ed] = wenergy(c,l)`
```Ea = 88.2860 ```
```Ed = 1×4 2.1560 1.2286 1.4664 6.8630 ```

Obtain the wavelet packet tree corresponding to the 3-level wavelet packet decomposition of the signal using the `sym4` wavelet.

`t = wpdec(noisbump,3,wv);`

Obtain the percentages of energy in the terminal nodes.

`e = wenergy(t)`
```e = 1×8 95.0329 1.4664 0.6100 0.6408 0.5935 0.5445 0.5154 0.5965 ```

## Input Arguments

collapse all

Wavelet decomposition, specified as a vector. The vector contains the wavelet coefficients. The bookkeeping vector `l` contains the number of coefficients by level. See `wavedec`.

Data Types: `single` | `double`
Complex Number Support: Yes

Bookkeeping vector, specified as a vector of positive integers. The bookkeeping vector is used to parse the coefficients in the wavelet decomposition `c` by level. See `wavedec`.

Data Types: `single` | `double`

Wavelet packet tree, specified as a `wptree` object. See `wptree`, `wpdec`, and `wpdec2`.

## Output Arguments

collapse all

Percentage of energy corresponding to approximation coefficients, returned as a positive scalar.

Data Types: `single` | `double`

Percentage of energy corresponding to details coefficients, returned as a vector.

Data Types: `single` | `double`

Percentage of energy corresponding to the terminal nodes, returned as a vector.

Data Types: `single` | `double`

## Version History

Introduced before R2006a