Main Content

wt

Continuous wavelet transform with filter bank

Description

example

cfs= wt(fb,x)returns the continuous wavelet transform (CWT) coefficients of the signalx, usingfb, a CWT filter bank.xis a real- or complex-valued vector.xmust have at least 4 samples. Ifxis real-valued,cfsis a 2-D matrix, where each row corresponds to one scale. The column size ofcfsis equal to the length ofx. Ifxis complex-valued,cfsis 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 component).

[cfs,f] = wt(fb,x)returns the frequenciesfcorresponding to the scales (rows) ofcfsif theSamplingPeriodproperty is not specified in the CWT filter bankfb. If you do not specify a sampling frequency,fis in cycles/sample.

[cfs,f,coi] = wt(fb,x)returns the cone of influencecoifor the CWT.coiis in the same units asf. If the inputxis complex, thecoiapplies to both pages ofcfs.

example

[cfs,f,coi,scalcfs] = wt(fb,x)returns the scaling coefficientsscalcfsfor the wavelet transform. Scaling coefficients are not supported for the bump wavelet.

[cfs,p] = wt(fb,x)returns the periodspcorresponding to the scales (rows) ofcfsif you specify a sampling period in the CWT filter bank.phas the same units and format as the duration scalar sampling period.

[cfs,p,coi] = wt(fb,x)returns the cone of influencecoiin periods for the CWT.coiis an array of durations with the same format property as the sampling period. If the inputxis complex, thecoiapplies to both pages ofcfs.

[cfs,p,coi,scalcfs] = wt(fb,x)returns the scaling coefficientsscalcfsfor the wavelet transform. Scaling coefficients are not supported for the bump wavelet.

Examples

collapse all

Load the noisy Doppler signal. Create a CWT filter bank that can be applied to the signal.

loadnoisdoppfb = cwtfilterbank('SignalLength'元素个数(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)) shadingflatset(gca,'YScale','log') holdonplot(t,coi,'w-','LineWidth',3) xlabel('Time (Samples)') ylabel('Normalized Frequency (cycles/sample)') title('Scalogram')

图包含一个坐标轴对象。坐标轴对象with title Scalogram contains 2 objects of type surface, line.

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'periodic'.

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

图包含一个坐标轴对象。坐标轴对象with title Signal contains an object of type line.

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) holdon情节(t, sig-xrec1)网格onlegend('Using mean(sig)','Using scalcfs') title('Difference Between Reconstructions')

图包含一个坐标轴对象。坐标轴对象with title Difference Between Reconstructions contains 2 objects of type line. These objects represent Using mean(sig), Using scalcfs.

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) holdonplot(t,scalcfs) gridontitle('Comparing Scaling Coefficients with 2 Hz Component') xlabel('Time (sec)') legend('2 Hz Component','Scaling Coefficients')

图包含一个坐标轴对象。坐标轴对象with title Comparing Scaling Coefficients with 2 Hz Component contains 2 objects of type line. These objects represent 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.

loadkobefb = cwtfilterbank('SignalLength',numel(kobe),'SamplingFrequency',1);

Use thecwtfunction and take the CWT of the data 250 times. Display the elapsed time used.

num = 250; tic;fork=1:num cfs = cwt(kobe);endtoc
Elapsed time is 6.551628 seconds.

Now use thewtobject function of the filter bank to take the CWT of the data. Confirm using the filter bank is faster.

tic;fork=1:num cfs = wt(fb,kobe);endtoc
Elapsed time is 3.782376 seconds.

Input Arguments

collapse all

Continuous wavelet transform (CWT) filter bank, specified as acwtfilterbankobject.

Input signal, specified as a real- or complex-valued vector.xmust have at least four samples.

Data Types:double|single
Complex Number Support:Yes

输出Arguments

collapse all

Continuous wavelet transform, returned as a matrix or 3-D array of complex values. Ifxis real-valued,cfsis a 2-D matrix, where each row corresponds to one scale. The column size ofcfsis equal to the length ofx. Ifxis complex-valued,cfsis 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 component).

Frequencies, returned as a vector, corresponding to the scales (rows) ofcfsif the'SamplingPeriod'is not specified infb. If you specify a sampling frequency,fis in hertz. If you do not specify a frequency,fis in cycles/sample.

Data Types:double

Periods, returned as an array of durations, corresponding to the scales (rows) ofcfsiffbhas a specified sampling period.phas the same units and format as the duration scalar sampling period.

Data Types:duration

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,coiis an array of real numbers in the same units asf. If you specify a sampling period,coiis 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, seeBoundary Effects and the Cone of Influence.

Data Types:double|duration

Scaling coefficients for the wavelet transform, returned as a vector with the same length asx. Ifxis real-valued,scalcfsis real valued. Ifxis complex valued,scalcfsis complex valued.

Data Types:double

Tips

  • 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 acwtfilterbankobject and then use thewtobject function. This workflow minimizes overhead and maximizes performance. SeeUsing CWT Filter Bank on Multiple Time Series.

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

Introduced in R2018a