# icwt

Inverse continuous 1-D wavelet transform

## Syntax

## Description

inverts the
continuous wavelet transform (CWT) coefficient matrix `xrec`

= icwt(`cfs`

)`cfs`

using
Morlet's single integral formula. `icwt`

assumes that you
obtained the CWT using `cwt`

with the default analytic Morse
(3,60) wavelet. This wavelet has a symmetry of 3 and a time bandwidth of 60.
`icwt`

also assumes that the CWT uses default scales.

specifies one or more additional name-value arguments. For example, `xrec`

= icwt(___,`Name=Value`

)```
xrec =
icwt(cfs,TimeBandwidth=40,VoicesPerOctave=20)
```

specifies a
time-bandwidth product of 40 and 20 voices per octave.

## Examples

### Inverse Continuous Wavelet Transform of Speech Signal

Obtain the CWT of a speech sample and invert the CWT using the default analytic Morse wavelet.

```
load mtlb
cfs = cwt(mtlb);
xrec = icwt(cfs);
```

### Inverse Continuous Wavelet Transform Using Specified Wavelet

Obtain the continuous wavelet transform of a speech sample and reconstruct the sample using the bump wavelet instead of the default Morse wavelet.

```
load mtlb
dt = 1/Fs;
t = 0:dt:numel(mtlb)*dt-dt;
```

Obtain the CWT.

`bumpmtlb = cwt(mtlb,Fs,"bump");`

Obtain the inverse CWT. Add the signal mean to the output.

`xrec = icwt(bumpmtlb,"bump",SignalMean=mean(mtlb));`

Plot the original and reconstructed signals.

plot(t,mtlb) xlabel("Seconds") ylabel("Amplitude") hold on plot(t,xrec,"r") hold off axis tight legend("Original","Reconstruction")

If your computer has a sound card, you can listen to the original and reconstructed signals.

% To play the original signal, uncomment the next two lines % p = audioplayer(mtlb,Fs); % play(p) % To play the reconstructed signal, uncomment the next two lines % px = audioplayer(xrec,Fs); % play(px)

### Reconstruct Frequency-Localized Data

Reconstruct a frequency-localized approximation to the Kobe earthquake data by extracting information from the CWT. The sampling frequency is 1 Hz. The extracted information corresponds to frequencies in the range [0.030 0.070] Hz.

`load kobe`

Obtain the CWT. Then, obtain the inverse CWT and add the signal mean back into the reconstructed data. The CWT does not preserve the signal mean.

[cfs,f] = cwt(kobe,1); xrec = icwt(cfs,[],f,[0.030 0.070],SignalMean=mean(kobe));

Plot the original and reconstructed data.

subplot(2,1,1) plot(kobe) grid on title("Original Data") ylabel("Amplitude") axis tight subplot(2,1,2) plot(xrec) grid on title("Bandpass Filtered Reconstruction [0.030 0.070] Hz"); xlabel("Time (s)") ylabel("Amplitude") axis tight

### Reconstruct Data from Specific Time Period

Use the inverse continuous wavelet transform to reconstruct an approximation to El Nino data based on 2 to 8 year periods.

Load the El Nino data and obtain its CWT. The data is sampled monthly. To obtain the periods in years, specify the sampling interval as 1/12 of a year.

```
load ninoairdata
[cfs,period] = cwt(nino,years(1/12));
```

Obtain the inverse CWT for periods of 2 to 8 years.

xrec = icwt(cfs,[],period,[years(2) years(8)]);

Plot the CWT of the reconstructed data and compare it to the CWT of the original data.

cwt(nino,years(1/12))

ans = proplistener with properties: Object: {[1x1 Axes]} Source: {[1x1 matlab.graphics.internal.GraphicsMetaProperty]} EventName: 'PostSet' Callback: @changeYTickLabels Enabled: 1 Recursive: 0

`title("Original Data")`

figure cwt(xrec,years(1/12))

ans = proplistener with properties: Object: {[1x1 Axes]} Source: {[1x1 matlab.graphics.internal.GraphicsMetaProperty]} EventName: 'PostSet' Callback: @changeYTickLabels Enabled: 1 Recursive: 0

`title("Approximation Based on 2-8 Year Periods")`

Compare the original data with the reconstructed data in time.

figure subplot(2,1,1) plot(datayear,nino) grid on ax = gca; ax.XTickLabel = ''; axis tight title("Original Data") subplot(2,1,2) plot(datayear,xrec) grid on axis tight xlabel("Year") title("El Nino Data - 2-8 Year Periods")

### Reconstruct Complex Data with Time-varying Trend

Add a trend to the continuous wavelet transform of a complex-valued dataset and reconstruct.

Obtain the CWT of the NPG2006 dataset.

```
load npg2006.mat
cfs = cwt(npg2006.cx);
```

Create a time-varying trend derived from the data.

`trend = smoothdata(npg2006.cx,"movmean",100);`

Obtain the inverse CWT and add the trend. Plot the original data and the reconstructed data.

xrec = icwt(cfs,SignalMean=trend); plot([real(xrec)' real(npg2006.cx)]) grid on title("Real Values") legend("Trend","Original") axis tight

figure plot([imag(xrec)' imag(npg2006.cx)]) grid on title("Imaginary Values") legend("Trend","Original") axis tight

### Reconstruct Signal Using Analysis Filter Bank

Load an ECG waveform. Create a CWT filter bank with periodic boundary handling that you can apply to the waveform.

load wecg fb = cwtfilterbank(SignalLength=length(wecg),Boundary="periodic");

Obtain the two-sided frequency responses for the wavelet and scaling filters in the filter bank.

`psif = freqz(fb,FrequencyRange="twosided",IncludeLowpass=true);`

Use the filter bank to obtain the CWT of the waveform. Also obtain the scaling coefficients for the transform.

[cfs,~,~,scalcfs] = wt(fb,wecg);

Use the analysis filter bank to reconstruct the input. The approximate synthesis filters, or dual frame, are used to invert the transform.

```
xrecAN = icwt(cfs,[],ScalingCoefficients=scalcfs,...
AnalysisFilterBank=psif);
```

Reconstruct the input using the default Morlet single integral formula.

xrecSI = icwt(cfs,[],ScalingCoefficients=scalcfs);

Compare the maximum reconstruction errors.

errAN = norm(xrecAN'-wecg,Inf)

errAN = 6.6613e-16

errSI = norm(xrecSI'-wecg,Inf)

errSI = 0.4037

Plot both reconstructions.

subplot(2,1,1) plot([xrecAN' wecg]) axis tight legend("Synthesis Filters","Original",Location="eastoutside") subplot(2,1,2) plot([xrecSI' wecg]) axis tight legend("Single Integral","Original",Location="eastoutside")

## Input Arguments

`cfs`

— Continuous wavelet transform coefficients

matrix

Continuous wavelet transform coefficients, specified as a matrix of
complex values. `cfs`

is the output from the `cwt`

function.

If `cfs`

is a 2-D matrix, `icwt`

assumes that the CWT was obtained from a real-valued signal. If
`cfs`

is a 3-D matrix, `icwt`

assumes that the CWT was obtained from a complex-valued signal. For a 3-D
matrix, the first page of the `cfs`

is the CWT of the
positive (counterclockwise) component and the second page of
`cfs`

is the negative (clockwise) component. The
pages represent the analytic and anti-analytic parts of the CWT,
respectively.

**Data Types: **`single`

| `double`

**Complex Number Support: **Yes

`wname`

— Analytic wavelet

`'morse"`

(default) | `"amor"`

| `"bump"`

Analytic wavelet used to invert the CWT, specified as one of these:

`"morse"`

— Morse wavelet`"amor"`

— Morlet wavelet`"bump"`

— bump wavelet

The specified wavelet must be the same wavelet used to obtain the CWT. The default Morse wavelet uses a symmetry parameter, $$\gamma $$, that is 3 and a time bandwidth of 60.

`freqrange`

— Frequency range

two-element vector | 2-by-2 matrix

Frequency range for which to return inverse continuous wavelet transform values, specified as a two-element vector or 2-by-2 matrix.

If

`cfs`

is a 2-D matrix,`freqrange`

must be a two-element vector.If

`cfs`

is a 3-D matrix,`freqrange`

can be a two-element vector or a 2-by-2 matrix.If

`freqrange`

is a vector,`icwt`

inverts the CWT over the same frequency range in both the positive (analytic) and negative (anti-analytic) components of`cfs`

.If

`freqrange`

is a 2-by-2 matrix, the first row contains the frequency range for the positive part of`cfs`

(first page) and the second row contains the frequency range for the negative part of`cfs`

(second page).

For a vector, the elements of `freqrange`

must be strictly increasing and contained in the range of the frequency
vector `f`

. For a matrix, each row of
`freqrange`

must be strictly increasing and contained
in the range of `f`

. `f`

is the
scale-to-frequency conversion obtained in CWT. For the inversion of a
complex-valued signal, you can specify one row of
`freqrange`

as a vector of zeros. If the first row of
`freqrange`

is a vector of zeros, only the negative
(anti-analytic part) is used in the inversion.

If you specify `freqrange`

, you must also specify
`f`

.

For example `[0 0; 1/10 1/4]`

inverts the negative
(clockwise) component over the frequency range```
[1/10
1/4]
```

. The positive (counterclockwise) component is first set to
all zeros before performing the inversion. Similarly, ```
[1/10 1/4; 0
0]
```

inverts the CWT by selecting the frequency range
`[1/10 1/4]`

from the positive (counterclockwise)
component and setting the negative component to all zeros.

**Data Types: **`single`

| `double`

`period`

— Time periods

vector

Time periods corresponding to the rows of CWT coefficient matrix `cfs`

,
specified as a vector. `period`

is the output of `cwt`

,
when the CWT is obtained using a `duration`

input.

**Data Types: **`duration`

`periodrange`

— Period range

two-element vector | 2-by-2 matrix

Period range for which to return inverse continuous wavelet transform values, specified as a two-element vector or 2-by-2 matrix.

If

`cfs`

is a 2-D matrix,`periodrange`

must be a two-element vector of durations.If

`cfs`

is a 3-D matrix,`periodrange`

can be a two-element vector of durations or 2-by-2 matrix of durations.If

`periodrange`

is a vector of durations,`icwt`

inverts the CWT over the same frequency range in both the positive (analytic) and negative (anti-analytic) components of`cfs`

.If

`periodrange`

is a 2-by-2 matrix of durations, the first row contains the period range for the positive part of`cfs`

(first page) and the second row contains the period range for the negative part of`cfs`

(second page).

For a vector, the elements of
`periodrange`

must be strictly increasing and
contained in the range of the period vector `period`

. The
elements of `periodrange`

and `period`

must have the same units. For a matrix, each row of
`periodrange`

must be strictly increasing and
contained in the range of the period vector P. For the inversion of a
complex-valued signal, you can specify one row of
`periodrange`

as a vector of zero durations. If the
first row of `periodrange`

is a vector of zero durations,
only the negative (anti-analytic part) is used in the inversion.

If you specify `periodrange`

, you must also specify
`period`

.

For example ```
[seconds(0) seconds(0); seconds(1/10)
seconds(1/4)]
```

inverts the negative(clockwise) component over
the period range `[seconds(1/10) seconds(1/4)]`

. The
positive (counterclockwise) component is first set to all zeros before
performing the inversion. Similarly, ```
[seconds(1/10) seconds(1/4);
seconds(0) seconds(0)]
```

inverts the CWT by selecting the
period range `[1/10 1/4]`

from the positive
(counterclockwise) component and setting the negative component to all
zeros.

**Data Types: **`duration`

### Name-Value Arguments

Specify optional pairs of arguments as
`Name1=Value1,...,NameN=ValueN`

, where `Name`

is
the argument name and `Value`

is the corresponding value.
Name-value arguments must appear after other arguments, but the order of the
pairs does not matter.

**Example: **`xrec = icwt(cfs,"bump",VoicesPerOctave=10)`

returns the
inverse CWT of `cfs`

using the bump wavelet and 10 voices per
octave.

*
Before R2021a, use commas to separate each name and value, and enclose*
`Name`

*in quotes.*

**Example: **```
xrec = icwt(cfs,"WaveletParameters",[3
40],"SignalMean",sigmean)
```

inverts the CWT using the Morse (3,40)
wavelet and signal mean `sigmean`

.

`TimeBandwidth`

— Time-bandwidth of Morse wavelet

`60`

(default) | scalar greater than 3 and less than or equal to 120

Time bandwidth of the Morse wavelet, specified as a scalar greater than 3 and less than or
equal to 120. The specified time bandwidth must be the same
time-bandwidth value used in the `cwt`

. The symmetry
of the Morse wavelet is assumed to be 3.

If you specify `TimeBandwidth`

, you cannot specify
`WaveletParameters`

.

This syntax is not valid if you specify the
`AnalysisFilterBank`

name-value argument.

**Data Types: **`single`

| `double`

`WaveletParameters`

— Symmetry and time bandwidth of Morse wavelet

`[3,60]`

(default) | two-element vector of scalars

Symmetry and time bandwidth of Morse wavelet, specified as a two-element vector of scalars. The first element of the vector is the symmetry, $$\gamma $$, and the second element is the time-bandwidth. The specified wavelet parameters must be the same values used in the CWT.

If you specify `WaveletParameters`

, you cannot specify
`TimeBandwidth`

.

This syntax is not valid if you specify the
`AnalysisFilterBank`

name-value argument.

**Data Types: **`single`

| `double`

`SignalMean`

— Signal mean

scalar | vector

Signal mean to add to the `icwt`

output, specified
as a scalar or vector. If the signal mean is a vector, it must be the
same length as the column size of the wavelet coefficient matrix
`cfs`

.

If

`cfs`

is a 2-D matrix, the signal mean must be a real-valued scalar or vector.If

`cfs`

is a 3-D matrix, the signal mean must be a complex-valued scalar or vector.

Because `cwt`

does not preserve the
signal mean, the inverse CWT is a zero-mean signal by default. Adding a
non-zero signal mean to a frequency- or period-limited reconstruction
adds a zero-frequency component to the reconstruction.

This syntax is not valid if you specify the
`AnalysisFilterBank`

name-value argument.

**Data Types: **`single`

| `double`

**Complex Number Support: **Yes

`ScalingCoefficients`

— Scaling coefficients

real- or complex-valued vector

Scaling coefficients to use in the inverse CWT, specified as a real-
or complex-valued vector, obtained as an optional output of `cwt`

. The length of
`ScalingCoefficients`

is equal to the column size
of `cfs`

.

If you only specify

`ScalingCoefficients`

without the`AnalysisFilterBank`

name-value argument, the single-integral approximation is used to obtain the inverse CWT.If you specify

`ScalingCoefficients`

with the`AnalysisFilterBank`

name-value argument, the synthesis filters are used to obtain the inverse CWT.

You cannot specify both `SignalMean`

and
`ScalingCoefficients`

name-value
arguments.

**Data Types: **`single`

| `double`

**Complex Number Support: **Yes

`AnalysisFilterBank`

— Analysis filters

real-valued matrix

Bank of analysis filters used in inverting the CWT, specified as a matrix. The approximate synthesis filters, or dual frame, are used in the inversion. In most cases, use of the approximate synthesis filters results in a more accurate signal reconstruction. The wavelet name input is ignored if you specify the analysis filters.

To use the analysis filters, you must obtain the CWT with
`ExtendSignal`

set to `false`

in
`cwt`

, or equivalently,
`Boundary`

set to `"periodic"`

in
`cwtfilterbank`

. Obtain the analysis filters from the
`freqz`

object function of the filter bank with
`FrequencyRange="twosided"`

and
`IncludeLowpass=true`

.

**Data Types: **`single`

| `double`

`VoicesPerOctave`

— Number of voices per octave

`10`

(default) | integer from 1 to 48

Number of voices per octave used in inverting the CWT, specified as an integer from 1 to 48. The CWT scales are discretized using the specified number of voices per octave. The number of voices per octave must be the same value used to obtain the CWT.

You cannot specify the number of voices per octave if you specify
either the frequency, `f`

, or duration,
`period`

. This syntax is not valid if you specify
the `AnalysisFilterBank`

name-value argument.

**Data Types: **`single`

| `double`

## Output Arguments

`xrec`

— Inverse 1-D continuous wavelet transform

real- or complex-valued row vector

Inverse 1-D continuous wavelet transform, returned as a real- or complex-valued row vector.

**Data Types: **`single`

| `double`

**Complex Number Support: **Yes

## More About

### Inverse Continuous Wavelet Transform — Single Integral Formula

By default, `icwt`

computes the inverse CWT
based on a discretized version of the single integral formula due to Morlet [5]. For a brief
description of the theoretical foundation for the single integral formula, see Inverse Continuous Wavelet Transform. For additional theoretical
information, see section 2.4 of [6]. The
discretized version of this integral is presented in [7].

## References

[1] Lilly, J. M., and S. C. Olhede.
"Generalized Morse Wavelets as a Superfamily of Analytic Wavelets." *IEEE
Transactions on Signal Processing* 60, no. 11 (November 2012): 6036–41.
https://doi.org/10.1109/TSP.2012.2210890.

[2] Lilly, J.M., and S.C. Olhede.
"Higher-Order Properties of Analytic Wavelets." *IEEE Transactions on Signal
Processing* 57, no. 1 (January 2009): 146–60.
https://doi.org/10.1109/TSP.2008.2007607.

[3] Lilly, J. M. *jLab: A data
analysis package for Matlab*, version 1.6.2. 2016.
http://www.jmlilly.net/jmlsoft.html.

[4] Lilly, J. M., and J.-C.
Gascard. "Wavelet Ridge Diagnosis of Time-Varying Elliptical Signals with Application to
an Oceanic Eddy." *Nonlinear Processes in Geophysics* 13, no. 5
(September 14, 2006): 467–83. https://doi.org/10.5194/npg-13-467-2006.

[5] Duval-Destin, M., M. A.
Muschietti, and B. Torresani. “Continuous Wavelet Decompositions, Multiresolution, and
Contrast Analysis.” *SIAM Journal on Mathematical Analysis* 24, no.
3 (May 1993): 739–55. https://doi.org/10.1137/0524045.

[6] Daubechies, Ingrid.
*Ten Lectures on Wavelets*. CBMS-NSF Regional Conference Series
in Applied Mathematics 61. Philadelphia, Pa: Society for Industrial and Applied
Mathematics, 1992.

[7] Torrence, Christopher, and
Gilbert P. Compo. “A Practical Guide to Wavelet Analysis.” *Bulletin of the
American Meteorological Society* 79, no. 1 (January 1, 1998): 61–78.
https://doi.org/10.1175/1520-0477(1998)079<0061:APGTWA>2.0.CO;2.

[8] Holschneider, M., and Ph.
Tchamitchian. “Pointwise Analysis of Riemann’s 'Nondifferentiable' Function.”
*Inventiones Mathematicae* 105, no. 1 (December 1991): 157–75.
https://doi.org/10.1007/BF01232261.

## Extended Capabilities

### C/C++ Code Generation

Generate C and C++ code using MATLAB® Coder™.

## Version History

**Introduced in R2016b**

### R2022a: `icwt`

behavior change

If you invert the CWT over a specified frequency range or range of periods, you must precede those inputs either by a wavelet name or an empty input for the default Morse wavelet.

Functionality | Result | Use Instead | Compatibility Considerations |
---|---|---|---|

`xrec = icwt(cfs,f,freqrange)`
| Errors | `xrec = icwt(cfs,[],f,freqrange)` or
`xrec = icwt(cfs,"morse",f,freqrange)`
| You do not have to specify the default Morse wavelet if you
are only setting `Name=Value` arguments. For
example, ```
xrec =
icwt(cfs,TimeBandwidth=40)
``` . |

```
xrec =
icwt(cfs,f,freqrange,Name=Value)
``` | Errors | `xrec = icwt(cfs,[],f,freqrange,Name=Value)`
or ```
xrec =
icwt(cfs,"morse",f,freqrange,Name=Value)
```
| |

`xrec = icwt(cfs,period,periodrange)`
| Errors | `xrec = icwt(cfs,[],period,periodrange)` or
```
xrec =
icwt(cfs,"morse",period,periodrange)
```
| |

```
xrec =
icwt(cfs,period,periodrange,Name=Value)
``` | Errors | ```
xrec =
icwt(cfs,[],period,periodrange,Name=Value)
``` or
```
xrec =
icwt(cfs,"morse",period,periodrange,Name=Value)
``` |

### R2022a: Data type of wavelet and scaling coefficients must match for `icwt`

If you specify `ScalingCoefficients`

, the scaling coefficients
must have the same data type as the wavelet coefficients `cfs`

.
Both sets of coefficients must be either single or double precision.

Note that the wavelet and scaling coefficient outputs of `cwt`

and the `wt`

method of `cwtfilterbank`

always have the same data type.

## Apri esempio

Si dispone di una versione modificata di questo esempio. Desideri aprire questo esempio con le tue modifiche?

## Comando MATLAB

Hai fatto clic su un collegamento che corrisponde a questo comando MATLAB:

Esegui il comando inserendolo nella finestra di comando MATLAB. I browser web non supportano i comandi MATLAB.

# Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

You can also select a web site from the following list:

## How to Get Best Site Performance

Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.

### Americas

- América Latina (Español)
- Canada (English)
- United States (English)

### Europe

- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)

- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)