# lwtcoef

Extract or reconstruct 1-D LWT wavelet coefficients

## Syntax

```Y = lwtcoef(TYPE,XDEC,LS,LEVEL,LEVEXT) Y = lwtcoef(TYPE,XDEC,W,LEVEL,LEVEXT) ```

## Description

`Y = lwtcoef(TYPE,XDEC,LS,LEVEL,LEVEXT)` returns the coefficients or the reconstructed coefficients of level `LEVEXT`, extracted from `XDEC`, the LWT decomposition at level `LEVEL` obtained with the lifting scheme `LS`.

The valid values for `TYPE` are

TYPE Values

Description

`'a'`

Approximations

`'d'`

Details

`'ca' `

Coefficients of approximations

`'cd'`

Coefficients of details

`Y = lwtcoef(TYPE,XDEC,W,LEVEL,LEVEXT)` returns the same output using `W`, which is the name of a lifted wavelet.

## Examples

```% Start from the Haar wavelet and get the % corresponding lifting scheme. lshaar = liftwave('haar'); % Add a primal ELS to the lifting scheme. els = {'p',[-0.125 0.125],0}; lsnew = addlift(lshaar,els); % Perform LWT at level 2 of a simple signal. x = 1:8; xDec = lwt(x,lsnew,2) xDec = 4.3438 0.7071 2.1250 0.7071 13.0313 0.7071 2.0000 0.7071 % Extract approximation coefficients of level 1. ca1 = lwtcoef('ca',xDec,lsnew,2,1) ca1 = 1.9445 4.9497 7.7782 10.6066 % Reconstruct approximations and details. a1 = lwtcoef('a',xDec,lsnew,2,1) a1 = 1.3750 1.3750 3.5000 3.5000 5.5000 5.5000 7.5000 7.5000 a2 = lwtcoef('a',xDec,lsnew,2,2) a2 = 2.1719 2.1719 2.1719 2.1719 6.5156 6.5156 6.5156 6.5156 d1 = lwtcoef('d',xDec,lsnew,2,1) d1 = -0.3750 0.6250 -0.5000 0.5000 -0.5000 0.5000 -0.5000 0.5000 d2 = lwtcoef('d',xDec,lsnew,2,2) d2 = -0.7969 -0.7969 1.3281 1.3281 -1.0156 -1.0156 0.9844 0.9844 % Check perfect reconstruction. err = max(abs(x-a2-d2-d1)) err = 9.9920e-016 ``` 