# cwt

Continuous 1-D wavelet transform

This version of `cwt` is no longer recommended. Use the updated `cwt` instead.

## Syntax

```coefs = cwt(x,scales,'wname') coefs = cwt(x,scales,'wname','plot') coefs = cwt(x,scales,'wname','coloration') coefs = cwt(x,scales,'wname','coloration',xlim) [coefs,sgram] = cwt(x,scales,'wname','scal') [coefs,sgram] = cwt(x,scales,'wname','scalCNT') [coefs,frequencies] = cwt(x,scales,wname, samplingperiod) [coefs,sgram,frequencies] = cwt(x,scales,wname, samplingperiod,'scal') ```

## Description

`coefs = cwt(x,scales,'wname')` returns the continuous wavelet transform (CWT) of the real-valued signal `x`. The wavelet transform is computed for the specified scales using the analyzing wavelet `wname`. `scales` is a 1-D vector with positive elements. The character vector or string scalar `wname` denotes a wavelet recognized by `wavemngr`. `coefs` is a matrix with the number of rows equal to the length of `scales` and number of columns equal to the length of the input signal. The k-th row of `coefs` corresponds to the CWT coefficients for the k-th element in the scales vector.

`coefs = cwt(x,scales,'wname','plot')` plots the continuous wavelet transform coefficients, using default `coloration` `'absglb'`.

`coefs = cwt(x,scales,'wname','coloration')` uses the specified coloration. See More About for coloration options.

`coefs = cwt(x,scales,'wname','coloration',xlim)` colors the coefficients using coloration and `xlim`, where `xlim` is a vector, `[x1 x2]`, with 1 ≤ `x1` < `x2``length(x)`.

`[coefs,sgram] = cwt(x,scales,'wname','scal')` returns and plots the scalogram. `'scal'` produces an image plot of the scalogram.

`[coefs,sgram] = cwt(x,scales,'wname','scalCNT')` displays a contour representation of the scalogram.

```[coefs,frequencies] = cwt(x,scales,wname, samplingperiod)``` returns the frequencies in cycles per unit time corresponding to the scales and the analyzing wavelet `wname`. `samplingperiod` is a positive real-valued scalar. If the units of `samplingperiod` are seconds, the frequencies are in hertz.

```[coefs,sgram,frequencies] = cwt(x,scales,wname, samplingperiod,'scal')``` returns the scalogram and the frequencies corresponding to the scales and the analyzing wavelet. If you have at least two elements in `scales`, you can also use the flag `'scalCNT' ` to output the scalogram. The `samplingperiod` is only used in the conversion of scales to frequencies. Specifying `samplingperiod` does not affect the appearance of plots generated by `cwt`.

## Examples

Plot the continuous wavelet transform and scalogram using sym2 wavelet at all integer scales from 1 to 32, using a fractal signal as input:

```load vonkoch vonkoch=vonkoch(1:510); len = length(vonkoch); cw1 = cwt(vonkoch,1:32,'sym2','plot'); title('Continuous Transform, absolute coefficients.') ylabel('Scale') [cw1,sc] = cwt(vonkoch,1:32,'sym2','scal'); title('Scalogram') ylabel('Scale') ```

Compare discrete and continuous wavelet transforms, using a fractal signal as input:

```load vonkoch vonkoch=vonkoch(1:510); len=length(vonkoch); [c,l]=wavedec(vonkoch,5,'sym2'); % Compute and reshape DWT to compare with CWT. cfd=zeros(5,len); for k=1:5 d=detcoef(c,l,k); d=d(ones(1,2^k),:); cfd(k,:)=wkeep(d(:)',len); end cfd=cfd(:); I=find(abs(cfd) <sqrt(eps)); cfd(I)=zeros(size(I)); cfd=reshape(cfd,5,len); % Plot DWT. subplot(311); plot(vonkoch); title('Analyzed signal.'); set(gca,'xlim',[0 510]); subplot(312); image(flipud(wcodemat(cfd,255,'row'))); colormap(pink(255)); set(gca,'yticklabel',[]); title('Discrete Transform,absolute coefficients'); ylabel('Level'); % Compute CWT and compare with DWT subplot(313); ccfs=cwt(vonkoch,1:32,'sym2','plot'); title('Continuous Transform, absolute coefficients'); set(gca,'yticklabel',[]); ylabel('Scale'); ``` collapse all

### Scale Values

Scale values determine the degree to which the wavelet is compressed or stretched. Low scale values compress the wavelet and correlate better with high frequencies. The low scale CWT coefficients represent the fine-scale features in the input signal vector. High scale values stretch the wavelet and correlate better with the low frequency content of the signal. The high scale CWT coefficients represent the coarse-scale features in the input signal.

### Coloration

Coloration is the method used to scale the coefficient values for plotting. Each coefficient is divided by the resulting coloration value.

• `'lvl'` — uses maximum value in each scale

• `'glb'` — uses maximum value in all scales

• `'abslvl'` or `'lvlabs'` — uses maximum absolute value in each scale

• `'absglb'` or `'glbabs'` — uses maximum absolute value in all scales

• `'scal'` — produces a scaled image of the scalogram

• `'scalCNT'` — produces a contour representation of the scalogram

For 3-D plots (surfaces), use the `coloration` parameter preceded by `'3D'`, such as `coefs = cwt(...,'3Dplot')` or ```coefs = cwt(...,'3Dlvl')```` ...`

### Scalogram

Scalograms are plots that represent the percentage energy for each coefficient.

## References

Daubechies, I. Ten Lectures on Wavelets, Philadelphia, PA: Society for Industrial and Applied Mathematics (SIAM), 1992.

Mallat, S. A Wavelet Tour of Signal Processing, San Diego, CA: Academic Press, 1998.

### Topics

Introduced before R2006a

## Support Get trial now