Continuous wavelet transform with filter bank
returns the continuous wavelet transform (CWT) coefficients of the signal
cfs = wt(
fb, a CWT filter bank.
x is a real- or complex-valued vector.
x must have at least 4 samples. If
cfs is a 2-D matrix, where each row corresponds
to one scale. The column size of
cfs is equal to the length of
x is complex-valued,
cfs is a 3-D array, 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
Load the noisy Doppler signal. Create a CWT filter bank that can be applied to the signal.
load noisdopp fb = cwtfilterbank('SignalLength',numel(noisdopp));
Use the filter bank to obtain the continuous wavelet transform of the signal.
[cfs,f,coi] = wt(fb,noisdopp);
Plot the CWT scalogram, including the cone of influence.
t = 0:numel(noisdopp)-1; pcolor(t,f,abs(cfs)) shading flat set(gca,'YScale','log') hold on plot(t,coi,'w-','LineWidth',3) xlabel('Time (Samples)') ylabel('Normalized Frequency (cycles/sample)') title('Scalogram')
Create and plot a signal sampled at 1000 Hz. Create a CWT filter bank that can be used on the signal. Since the signal is periodic, set the boundary extension property of the filter bank to
Fs = 1000; t = 0:1/Fs:1-1/Fs; sig = 3*sin(2*pi*20*t) + cos(2*pi*2*t); fb = cwtfilterbank('SignalLength',length(sig),'SamplingFrequency',Fs,'Boundary','periodic'); plot(t,sig) xlabel('Time (sec)') title('Signal')
Take the CWT of the signal. Return the wavelet and scaling coefficients.
[cfs,~,~,scalcfs] = wt(fb,sig);
Reconstruct the signal two ways. First use the mean of the signal, then use the scaling coefficients. Plot the difference between the original signal and both reconstructions.
xrec0 = icwt(cfs,'SignalMean',mean(sig)); xrec1 = icwt(cfs,'ScalingCoefficients',scalcfs); plot(t,sig-xrec0) hold on plot(t,sig-xrec1) grid on legend('Using mean(sig)','Using scalcfs') title('Difference Between Reconstructions')
The scaling coefficients results in a significantly more accurate reconstruction. To investigate the source of the dramatic improvement, create a second signal consisting of the 2 Hz component of the original signal. Compare the scaling coefficients with the 2 Hz signal. The scaling coefficients and 2 Hz signal are virtually identical. Using the scaling coefficients helps with the reconstruction because the 2 Hz component is not representable by a wavelet with this sampling frequency and length.
figure sig2hz = cos(2*pi*2*t); plot(t,sig2hz) hold on plot(t,scalcfs) grid on title('Comparing Scaling Coefficients with 2 Hz Component') xlabel('Time (sec)') legend('2 Hz Component', 'Scaling Coefficients')
This example shows how using a CWT filter bank improves computational efficiency when taking the CWT of multiple time series.
Load the seismograph data recorded during the 1995 Kobe earthquake. The data are seismograph (vertical acceleration, nm/sq.sec) measurements recorded at Tasmania University, Hobart, Australia on 16 January 1995 beginning at 20:56:51 (GMT) and continuing for 51 minutes at 1 second intervals. Create a CWT filter bank that can be applied to the data.
load kobe fb = cwtfilterbank('SignalLength',numel(kobe),'SamplingFrequency',1);
cwt function and take the CWT of the data 250 times. Display the elapsed time used.
num = 250; tic; for k=1:num cfs = cwt(kobe); end toc
Elapsed time is 6.551628 seconds.
Now use the
wt object function of the filter bank to take the CWT of the data. Confirm using the filter bank is faster.
tic; for k=1:num cfs = wt(fb,kobe); end toc
Elapsed time is 3.782376 seconds.
fb— Continuous wavelet transform filter bank
Continuous wavelet transform (CWT) filter bank, specified as a
x— Input signal
Input signal, specified as a real- or complex-valued vector.
x must have at least four samples.
Complex Number Support: Yes
cfs— Continuous wavelet transform
Continuous wavelet transform, returned as a matrix or 3-D array of complex
x is real-valued,
is a 2-D matrix, where each row corresponds to one scale. The column size of
cfs is equal to the length of
x is complex-valued,
cfs is a 3-D array, 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
coi— Cone of influence
Cone of influence for the CWT, returned as either an array of real numbers
or an array of durations. The cone of influence indicates where edge effects
occur in the CWT. If you specify a sampling frequency,
coi is an array of real numbers in the same units
f. If you specify a sampling period,
coi is an array of durations with the same format
property as the sampling period. Due to the edge effects, give less credence
to areas that are outside or overlap the cone of influence.
For additional information, see Boundary Effects and the Cone of Influence.
scalcfs— Scaling coefficients
Scaling coefficients for the wavelet transform, returned as a vector with
the same length as
scalcfs is real valued. If
x is complex valued,
is complex valued.
The first time you use a filter bank to take the CWT of a signal, the wavelet filters are constructed to have the same datatype as the signal. A warning message is generated when you apply the same filter bank to a signal with a different datatype. Changing datatypes comes with the cost of redesigning or changing the precision of the filter bank. For optimal performance, use a consistent datatype.
When performing multiple CWTs, for example inside a for-loop, the recommended
workflow is to first create a
cwtfilterbank object and then use
wt object function. This workflow minimizes overhead
and maximizes performance. See Using CWT Filter Bank on Multiple Time Series.
This function fully supports GPU arrays. For more information, see Run MATLAB Functions on a GPU (Parallel Computing Toolbox).