主要内容

pat2cwav

Build wavelet from pattern

Description

[psi,xval,nc] = pat2cwav(ypat,method,poldegree,regularity) returns an admissible wavelet psi for the continuous wavelet transform (CWT) adapted to the pattern ypat. The wavelet psi is evaluated at xval, a regular grid in the interval [0,1], and has L2-norm equal to 1.

The constant nc is such that nc×psi approximates ypat on the interval [0,1] by least-squares fitting using the method specified by method, and a polynomial of degree poldegree with boundary constraints specified by regularity.

example

Examples

collapse all

This example illustrates how to generate a new wavelet starting from a pattern.

The principle for designing a new wavelet for CWT is to approximate a given pattern using least-squares optimization under constraints leading to an admissible wavelet well suited for the pattern detection using the continuous wavelet transform [1].

Load and plot a pattern.

load ptpssin1
plot(X,Y)
grid on
title('Original Pattern')

Figure contains an axes object. The axes object with title Original Pattern contains an object of type line.

Integrate the pattern over the interval. The integral does not equal 0. However, the pattern is a good candidate since it oscillates like a wavelet.

dX = X(2)-X(1);
patternInt = dX*sum(Y);
disp(['Integral: ',num2str(patternInt)]);
Integral: 0.15915

To synthesize a new wavelet adapted to the given pattern, use a least-squares polynomial approximation of degree 6 with constraints of continuity at the beginning and the end of the pattern.

[psi,xval,nc] = pat2cwav(Y,'polynomial',6,'continuous');

Plot the new wavelet.

plot(X,Y,'-',xval,nc*psi,'--')
grid on
legend('Original Pattern','Adapted Wavelet','Location','NorthWest')

Figure contains an axes object. The axes object contains 2 objects of type line. These objects represent Original Pattern, Adapted Wavelet.

Check that psi satisfies the definition of a wavelet by confirming that it integrates to zero and has L2 norm is equal to 1.

dxval = xval(2)-xval(1);
psiIntegral = dxval*sum(psi);
disp(['Integral: ',num2str(psiIntegral)])
Integral: 1.9626e-05
psiSqN = dxval*sum(psi.^2);
disp(['L2-norm: ',num2str(psiSqN)])
L2-norm: 1

Input Arguments

collapse all

Pattern to approximate, specified as a real-valued vector.

Least-squares fitting method to use to approximate the pattern, specified as one of the following:

  • 'polynomial' — Use a polynomial of degree poldegree

  • 'orthconst' — Use a projection onto the space of functions orthogonal to constants

Note

Specifying the 'orthconst' option does not produce an orthogonal wavelet. Any wavelet psi produced using pat2cwav is a type 4 wavelet (wavelet without a scaling function) in wavemngr.

Degree of polynomial to use in least-squares fitting, specified as an integer.

Boundary constraints at the points 0 and 1, specified as 'continuous', 'differentiable', or 'none'. When method is equal to 'polynomial':

  • If regularity is equal to 'continuous', poldegree must be greater than or equal to 3.

  • If regularity is equal to 'differentiable', poldegree must be greater than or equal to 5.

Output Arguments

collapse all

Admissible wavelet for CWT, returned as a real-valued vector. The length of psi equals the length of ypat. The wavelet psi integrates to zero and has L2-norm equal to 1.

Sampling instants where psi is evaluated, returned as a real-valued vector. The sampling instants xval are a regular n-point grid spanning the interval [0,1], where n is the length of ypat: xval = linspace(0,1,length(ypat)).

Normalizing constant, returned as a scalar. The constant nc is such that nc×psi approximates ypat on the interval [0,1] by least-squares fitting using the method specified by method.

References

[1] Misiti, M., Y. Misiti, G. Oppenheim, and J.-M. Poggi. Les ondelettes et leurs applications. France: Hermes Science/Lavoisier, 2003.

Version History

Introduced before R2006a

See Also