Accelerating the pace of engineering and science

cwt

Continuous 1-D wavelet transform

Syntax

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

Description

coefs = cwt(x,scales,'wname') computes the continuous wavelet transform (CWT) coefficients of the real-valued signal x at real, positive scales, using wavelet 'wname' (see waveinfo for more information). The analyzing wavelet can be real or complex. coefs is an la-by-lx matrix, where la is the length of scales and lx is the length of the input x. coefs is a real or complex matrix, depending on the wavelet type.

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.

[coefs,sgram] = cwt(x,scales,'wname','scal') displays a scaled image of the scalogram.

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

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

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');
```

expand 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.