Continuous 1-D wavelet transform
information on the older version of the
The older version is no longer recommended.
wt = cwt(x)
wt = cwt(x,wname)
[wt,f] = cwt(___,fs)
[wt,period] = cwt(___,ts)
[wt,f,coi] = cwt(___,fs)
[wt,period,coi] = cwt(___,ts)
[___] = cwt(___,Name,Value)
continuous wavelet transform (CWT) of
wt = cwt(
x. The input,
x, is a double-precision real- or complex-valued vector
and must have at least four samples. The CWT is obtained using the analytic
Morse wavelet with the symmetry parameter (gamma) equal to 3 and the
time-bandwidth product equal to 60.
cwt uses 10 voices per
octave. The minimum and maximum scales are determined automatically based on the
wavelet's energy spread in frequency and time. If
wt is a 2-D matrix where each row corresponds
to one scale. The column size of
wt is equal to the length
x is complex-valued,
wt is a 3-D matrix, where the first page is the CWT for
the positive scales (analytic part or counterclockwise component) and the second
page is the CWT for the negative scales (anti-analytic part or clockwise
specifies the sampling frequency,
fs, in Hz as a positive
fs to determine the
scale-to-frequency conversions and returns the frequencies,
f, in Hz. If you do not specify a sampling frequency,
f in cycles per
sample. If the input
x is complex, the scale-to-frequency
conversions apply to both pages of
specifies the sampling interval,
ts, as a positive
duration scalar. The
duration can be in years, days, hours, minutes, or
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. If the input
x is complex,
the scale-to-period conversions apply to both pages of
[___] = cwt(___, returns
the CWT with additional options specified by one or more
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 showing where edge effects become significant is also plotted.
Gray regions outside the dashed white line delineate regions where edge effects
are significant. If the input signal is complex-valued, the positive
(counterclockwise) and negative (clockwise) components are plotted in separate
If you do not specify a sampling frequency,
or time interval,
ts, the frequencies are plotted
in cycles per sample. If you specify a sampling frequency,
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
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.
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.
Create two complex exponentials, of different amplitudes, with frequencies of 32 and 64 Hz. The data is sampled at 1000 Hz. The two complex exponentials have disjoint support in time.
Fs = 1e3; t = 0:1/Fs:1; z = exp(1i*2*pi*32*t).*(t>=0.1 & t<0.3)+2*exp(-1i*2*pi*64*t).*(t>0.7);
Add complex white Gaussian noise with a standard deviation of 0.05.
wgnNoise = 0.05/sqrt(2)*randn(size(t))+1i*0.05/sqrt(2)*randn(size(t)); z = z+wgnNoise;
Obtain and plot the cwt using a Morse wavelet.
Note the magnitudes of the complex exponential components in the colorbar are essentially their amplitudes even though they are at different scales. This is a direct result of the L1 normalization. You can verify this by executing this script and exploring each subplot with a datacursor.
Obtain the CWT of Kobe earthquake data. The sampling frequency is 1 Hz.
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.
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.
x— Input signal
Input signal, specified as a row or column vector.
x is a
double-precision real- or complex-valued vector and must have at least four
wname— Analytic wavelet
Analytic wavelet used to compute the CWT, specified as
'bump'. These character
vectors specify the analytic Morse, Morlet, and 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.
fs— Sampling frequency
Sampling frequency, in Hz, specified as a positive scalar. If
fs, then you cannot specify
ts— Time duration
comma-separated pairs of
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
'ExtendSignal',falseindicates that the signal is not extended.
'ExtendSignal'— Extend input signal symmetrically
Option to extend the input signal symmetrically by reflection,
specified as the comma-separated pair consisting of
the signal symmetrically can mitigate boundary effects. If you specify
then the signal is extended. If you specify
then the signal is not extended.
'VoicesPerOctave'— Number of voices per octave
10(default) | even integer from 4 to 48
Number of voices per octave to use for the CWT, specified as
the comma-separated pair consisting of
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.
'NumOctaves'— Number of octaves
Number of octaves, specified as the comma-separated pair consisting
'NumOctaves' and a positive integer. The number
of octaves cannot exceed
NumOctaves value overrides the automatic
determination of the maximum scale. If you do not need to examine
lower frequency values, use a smaller
'TimeBandwidth'— Time-bandwidth product of Morse wavelet
Time-bandwidth product of the Morse wavelet, specified as the comma-separated pair consisting
'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.
The standard deviation of the Morse wavelet in time is approximately
If you specify
'TimeBandwidth', you cannot
'WaveletParameters'. To specify both the
symmetry and time-bandwidth product, use
'WaveletParameters'— Symmetry and time-bandwidth product of Morse wavelet
(3,60)(default) | two-element vector of scalars
Symmetry and time-bandwidth product of Morse wavelet, specified
as the comma-separated pair consisting of
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
wt— Continuous wavelet transform
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. If
x is real-valued,
wt is an
Na-by-N matrix, where
Na is the number of scales, and N
is the number of samples in
x is complex-valued,
wt is a
3-D matrix, where the first page is the CWT for the positive scales
(analytic part or counterclockwise component) and the second page is the CWT
for the negative scales (anti-analytic part or clockwise component). 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
Complex Number Support: Yes
Frequencies of the CWT, returned as a vector. If you specify
a sampling frequency,
in Hz. If you do not specify
cycles per sample.
period— Time periods
Time periods, returned as an array of durations. The durations
are in the same format as
ts. Each row corresponds
to a period.
coi— Cone of influence
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,
the cone of influence is in Hz. If you specify a time duration,
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.
To determine the minimum scale, first obtain the Fourier transform, 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:
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, , is approximately , where is the time-bandwidth product. The standard deviation in frequency, , is approximately . If you scale the wavelet by some , the time duration changes to , 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 .
Wavelet transform scales are powers of 2 and are denoted by . NV is the number of voices per octave, and j is from 0 to the largest scale. For a specific small scale, :
Converting to log2:
In integral form, the CWT preserves energy. However, when you implement the CWT
numerically, energy is not preserved. In this case, regardless of the normalization
you use, the CWT is not an orthonormal transform. The
function uses L1 normalization
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:
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 . 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. See example Continuous Wavelet Transform of Two Complex Exponentials.
 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.
 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.
 Lilly, J. M. jLab: A data analysis package for Matlab, version 1.6.2. 2016. http://www.jmlilly.net/jmlsoft.html.