# waverec

Multilevel 1-D discrete wavelet transform reconstruction

## Syntax

``x = waverec(c,l,wname)``
``x = waverec(c,l,LoR,HiR)``
``x = waverec(___,Mode=extmode)``

## Description

````x = waverec(c,l,wname)` reconstructs the 1-D signal `x` based on the multilevel wavelet decomposition structure [`c`,`l`] and the wavelet specified by `wname`. For more information, see `wavedec`.Note: `x = waverec(c,l,wname)` is equivalent to ```x = appcoef(c,l,wname,0)```.```
````x = waverec(c,l,LoR,HiR)` reconstructs the signal using the specified lowpass and highpass wavelet reconstruction filters `LoR` and `HiR`, respectively.```

example

````x = waverec(___,Mode=extmode)` uses the specified discrete wavelet transform (DWT) extension mode `extmode`. This syntax can be used with either of the previous syntaxes.```

## Examples

collapse all

`load wecg`

Perform a level 3 wavelet decomposition of the signal using the `db6` wavelet. Specify the `asym` extension mode.

`[c,l] = wavedec(wecg,3,"db6",Mode="asym");`

Reconstruct the signal using the wavelet decomposition structure. To ensure perfect reconstruction, specify the same extension mode used to obtain the decomposition.

`x = waverec(c,l,"db6",Mode="asym");`

Verify perfect reconstruction.

`err = norm(wecg-x)`
```err = 2.5198e-11 ```

## Input Arguments

collapse all

Wavelet decomposition, specified as a vector. The vector contains the wavelet coefficients. For more information, 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, specified as a character vector or string scalar. `wname` must specify the same wavelet used with `wavedec` to obtain the decomposition [`c`,`l`].

Note

`waverec` supports only Type 1 (orthogonal) or Type 2 (biorthogonal) wavelets. See `wfilters` for a list of orthogonal and biorthogonal wavelets.

Wavelet reconstruction filters, specified as a pair of even-length real-valued vectors. `LoR` is the lowpass reconstruction filter, and `HiR` is the highpass reconstruction filter. The lengths of `LoR` and `HiR` must be equal. For perfect reconstruction, `LoR` and `HiR` must be the reconstruction filters associated with the same wavelet used to obtain the wavelet decomposition `c` and `l`. For more information, see `wfilters`.

Data Types: `single` | `double`

Since R2023b

Extension mode to use for the inverse DWT, specified as:

`mode`

DWT Extension Mode

`"zpd"`

Zero extension

`"sp0"`

Smooth extension of order 0

`"spd"` (or``` "sp1"```)

Smooth extension of order 1

`"sym"` or `"symh"`

Symmetric extension (half point): boundary value symmetric replication

`"symw"`

Symmetric extension (whole point): boundary value symmetric replication

`"asym"` or `"asymh"`

Antisymmetric extension (half point): boundary value antisymmetric replication

`"asymw"`

Antisymmetric extension (whole point): boundary value antisymmetric replication

`"ppd"`, `"per"`

Periodized extension

If the signal length is odd and `mode` is `"per"`, an extra sample equal to the last value is added to the right and the extension is performed in `"ppd"` mode. If the signal length is even, `"per"` is equivalent to `"ppd"`.

The global variable managed by `dwtmode` specifies the default extension mode. For perfect reconstruction, use the same extension mode that was used to obtain `c` and `l` from `wavedec`.

## Output Arguments

collapse all

Reconstructed signal, returned as a vector.

 Daubechies, I. Ten Lectures on Wavelets, CBMS-NSF Regional Conference Series in Applied Mathematics. Philadelphia, PA: SIAM Ed, 1992.

 Mallat, S. G. “A Theory for Multiresolution Signal Decomposition: The Wavelet Representation,” IEEE Transactions on Pattern Analysis and Machine Intelligence. Vol. 11, Issue 7, July 1989, pp. 674–693.

 Meyer, Y. Wavelets and Operators. Translated by D. H. Salinger. Cambridge, UK: Cambridge University Press, 1995.