Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

cwt

Continuous 1-D wavelet transform

See cwt for information on the older version of the cwt. The older version is no longer recommended.

Syntax

  • [wt,f] = cwt(___,fs)
    example
  • [wt,period] = cwt(___,ts)
    example
  • [wt,f,coi] = cwt(___,fs)
    example
  • [wt,period,coi] = cwt(___,ts)
  • [___] = wtmm(___,Name,Value)
  • cwt(___)

Description

example

wt = cwt(x) returns the continuous wavelet transform (CWT). The input, x, must be a 1-D real-valued signal with at least four samples. cwt computes the continuous wavelet transform using the analytic Morse wavelet with a symmetry parameter of 3 and a time-bandwidth product of 60.

example

wt = cwt(x,wname) uses the analytic wavelet specified by wname to compute the CWT. Valid options for wname are 'morse', 'amor', and 'bump', which specify the Morse, Morlet, and bump wavelet, respectively.

example

[wt,f] = cwt(___,fs) specifies the sampling frequency, fs, in Hz as a positive scalar. cwt uses fs to determine the scale-to-frequency conversions and returns the frequencies, f, in Hz. If you do not specify a sampling frequency, cwt returns f in cycles per sample. You can use this syntax with any of the arguments from the previous syntaxes.

example

[wt,period] = cwt(___,ts) specifies the sampling interval, ts, as a positive duration scalar. The duration can be in years, days, hours, minutes, or seconds. cwt uses ts to compute the scale-to period conversion and returns the time periods in period. The array of durations in period have the same format property as ts.

example

[wt,f,coi] = cwt(___,fs) returns the cone of influence, coi, which shows where edge effects of the CWT become significant. The cone of influence for the CWT is in Hz.

[wt,period,coi] = cwt(___,ts) returns the cone of influence, coi, which shows where edge effects of the CWT become significant. The cone of influence for the CWT is in cycles per sample.

[___] = wtmm(___,Name,Value) returns the WTMM with additional options specified by one or more Name,Value pair arguments.

cwt(___) with no output arguments plots the CWT scalogram, which is the absolute value of the CWT as a function of time and frequency. The cone of influence is also plotted.

If you do not specify a sampling frequency, fs, or time interval, ts, the frequencies are plotted in cycles per sample. If you specify a sampling frequency, fs, the frequencies are in Hz. If you specify a sampling duration, the plot is a function of time and periods.

The y-axis of the scalogram uses a log2 scale. If you use a data cursor, the actual y-value is displayed. For example, if the axis value is approximately 0.125, the data cursor y-value is –3.01, which you can verify using pow2(3.01).

Examples

collapse all

Obtain the continuous wavelet transform of a speech sample using default values.

load mtlb;
w = cwt(mtlb);

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

load mtlb;
cwt(mtlb,'bump',Fs);

Compare the result obtained from the CWT using the default Morse wavelet.

cwt(mtlb,Fs);

Create two sine waves with frequencies of 32 and 64 Hz. The data is sampled at 1000 Hz. The two sine waves have disjoint support in time.

Fs = 1e3;
t = 0:1/Fs:1;
x = cos(2*pi*32*t).*(t>=0.1 & t<0.3) + sin(2*pi*64*t).*(t>0.7);

Add white Gaussian noise with a standard deviation of 0.05.

wgnNoise = 0.05*randn(size(t));
x = x + wgnNoise;

Obtain and plot the cwt using a Morse wavelet.

cwt(x,1000)

Obtain the CWT of Kobe earthquake data. The sampling frequency is 1 Hz.

load kobe;

Plot the earthquake data.

plot((1:numel(kobe))./60,kobe);
xlabel('mins');
ylabel('nm/s^2');
grid on
title('Kobe Earthquake Data');

Obtain the CWT, frequencies, and cone of influence.

[wt,f,coi] = cwt(kobe,1);

Plot the data, including the cone of influence.

cwt(kobe,1);

Obtain the CWT, time periods, and cone of influence by specifying a time duration instead of a sampling frequency.

[wt,periods,coi] = cwt(kobe,minutes(1/60));

View the same data by specifying a sampling period input instead of a frequency.

cwt(kobe,minutes(1/60));

Input Arguments

collapse all

Input signal, specified as a row or column vector. x must be a 1-D, real-valued signal with at least four samples.

Analytic wavelet used to compute the CWT, specified as 'morse', 'amor', or 'bump'. These character vectors specify the analytic Morse, Morlet, or bump wavelet, respectively.

The default Morse wavelet uses a symmetry parameter, γ, that is equal to 3 and has a time-bandwidth product that of 60.

Sampling frequency, in Hz, specified as a positive scalar. If you specify fs, then you cannot specify ts.

Time duration, also known as the sampling interval, specified as a positive duration scalar. Valid durations are years, days, hours, minutes, and seconds. You cannot use calendar durations. If you specify ts, then you cannot specify fs.

Example: wt = cwt(x,hours(12))

Data Types: duration

Name-Value Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside single quotes (' '). You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

Example: 'ExtendSignal',false indicates that the signal is not extended.

collapse all

Option to extend the input signal symmetrically by reflection, specified as the comma-separated pair consisting of 'ExtendSignal' and either true or false. Extending the signal symmetrically can mitigate boundary effects. If you specify true, then the signal is extended. If you specify false, then the signal is not extended.

Number of voices per octave to use for the CWT, specified as the comma-separated pair consisting of 'VoicesPerOctave' and an even integer from 4 to 48. The CWT scales are discretized using the specified number of voices per octave. The energy spread of the wavelet in frequency and time automatically determines the minimum and maximum scales.

Number of octaves, specified as the comma-separated pair consisting of 'NumOctaves' and a positive integer. The number of octaves cannot exceed floor(log2(numel(x)))-1. Specifying a NumOctaves value overrides the automatic determination of the maximum scale. If you do not need to examine lower frequency values, use a smaller NumOctaves value.

Time-bandwidth product of the Morse wavelet, specified as the comma-separated pair consisting of 'TimeBandwidth' and a scalar greater than 3 and less than or equal to 120. The symmetry parameter, gamma (γ), is fixed at 3. Wavelets with larger time-bandwidth products have larger spreads in time and narrower spreads in frequency.

If you specify 'TimeBandwidth', you cannot specify 'WaveletParameters'. To specify both the symmetry and time-bandwidth product, use 'WaveletParameters' instead.

Symmetry and time-bandwidth product of Morse wavelet, specified as the comma-separated pair consisting of 'WaveletParameters' and a two-element vector of scalars.

The first element is the symmetry, γ, which must be greater than or equal to 1. The second element is the time-bandwidth product which must be greater than γ. The ratio of the time-bandwidth product to γ cannot exceed 40.

When γ is equal to 3, the Morse wavelet is perfectly symmetric in the frequency domain and the skewness is 0. When γ is greater than 3, the skewness is positive. When γ is less than 3, the skewness is negative.

If you specify 'WaveletParameters', you cannot specify 'TimeBandwidth'.

Output Arguments

collapse all

Continuous wavelet transform, returned as a matrix of complex values. By default, cwt uses the analytic Morse (3,60) wavelet, where 3 is the symmetry and 60 is the time-bandwidth product. cwt uses 10 voices per octave. wt is an Na-by-N matrix, where Na is the number of scales, and N is the number of samples in x. The minimum and maximum scales are determined automatically based on the energy spread of the wavelet in frequency and time. See Algorithms for information on how the scales are determined.

Data Types: double
Complex Number Support: Yes

Frequencies of the CWT, returned as a vector. If you specify a sampling frequency, fs, then f is in Hz. If you do not specify fs, cwt returns f in cycles per sample.

Time periods, returned as an array of durations. The durations are in the same format as ts. Each row corresponds to a period.

Cone of influence for the CWT, returned as either an array of doubles or array of durations. The cone of influence indicates where edge effects occur in the CWT. If you specify a sampling frequency, fs, the cone of influence is in Hz. If you specify a time duration, ts, the cone of influence is in periods. Due to the edge effects, give less credence to areas that are outside or overlap the cone of influence.

More About

collapse all

Algorithms

Minimum Scale

To determine the minimum scale, first obtain the Fourier transform, ωx of the base wavelet. Then, find the peak frequency of that transformed data. For Morse wavelets, dilate the wavelet so that the Fourier transform of the wavelet at π radians is equal to 10% of the peak value. The smallest scale occurs at the largest frequency:

s0=ωx'π

As a result, the smallest scale is the minimum of (2, s0). For Morse wavelets, the smallest scale is usually s0. For the Morlet wavelet, the smallest scale is usually 2.

Maximum Scale

Both the minimum and maximum scales of the CWT are determined automatically based on the energy spread of the wavelet in frequency and time. To determine the maximum scale, CWT uses the following algorithm.

The standard deviation of the Morse wavelet in time, σt, is approximately P2, where P is the time-bandwidth product. The standard deviation in frequency, σf, is approximately 122P. If you scale the wavelet by some s>1, he time duration changes to 2sσt=N, which is the wavelet stretched to equal the full length (N samples) of the input. You cannot translate this wavelet or stretch it further without causing it to wrap, so the largest scale is floor(N2σt).

Wavelet transform scales are powers of 2 and are denoted by s0(21NV)j. NV is the number of voices per octave, and j is from 0 to the largest scale. For a specific small scale, s0:

s0(21NV)jN2σt

Converting to log2:

jlog2(21NV)log2(N2σts0)

jNVlog2N2σts0

Therefore, the maximum scale is

2floor(NVlog2N2σts0)

L1 Norm for CWT

Wavelet transforms commonly use L2 normalization of the wavelet. For the L2 norm, dilating a signal by 1/s, where s is greater than 0, is defined as follows:

x(ts)22=sx(t)22

The energy is now s times the original energy. To preserve the energy of the original signal, you must multiply the CWT by 1s. When included in the Fourier transform, multiplying by this factor produces different weights being applied to different scales, so that the peaks at higher frequencies are reduced more than the peaks at lower frequencies.

In many applications, L1 normalization is better. The L1 norm definition does not include squaring the value, so the preserving factor is 1/s instead of 1s. Instead of high-frequency amplitudes being reduced as in the L2 norm, for L1 normalization, all frequency amplitudes are normalized to the same value. Therefore, using the L1 norm shows a more accurate representation of the signal.

References

[1] Lilly, J. M., and S. C. Olhede. "Generalized Morse Wavelets as a Superfamily of Analytic Wavelets." IEEE Transactions on Signal Processing. Vol. 60, No. 11, 2012, pp. 6036–6041.

[2] Lilly, J. M., and S. C. Olhede. "Higher-Order Properties of Analytic Wavelets." IEEE Transactions on Signal Processing. Vol. 57, No. 1, 2009, pp. 146–160.

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

Introduced in R2016b

Was this topic helpful?