0% found this document useful (0 votes)
1K views

Continuous Wavelet Transform Coeff - Matlab Code

This document discusses reconstructing signals from their continuous wavelet transform (CWT) coefficients. It analyzes sensor data using the CWT to detect an oscillatory anomaly. The CWT reveals strong components at scale 6, indicating the anomaly. Only the coefficients at this scale are used to reconstruct an approximation of the anomaly signal. The process is repeated using linearly spaced scales centered on scale 6 to reconstruct the anomaly. Selective reconstruction of CWT coefficients in this way allows clearer visualization of the anomalous signal.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1K views

Continuous Wavelet Transform Coeff - Matlab Code

This document discusses reconstructing signals from their continuous wavelet transform (CWT) coefficients. It analyzes sensor data using the CWT to detect an oscillatory anomaly. The CWT reveals strong components at scale 6, indicating the anomaly. Only the coefficients at this scale are used to reconstruct an approximation of the anomaly signal. The process is repeated using linearly spaced scales centered on scale 6 to reconstruct the anomaly. Selective reconstruction of CWT coefficients in this way allows clearer visualization of the anomalous signal.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

4/1/13

Signal Reconstruction from Continuous Wavelet Transform Coefficients - MATLAB & Simulink Example - MathWorks India

Signal Reconstruction from Continuous Wavelet Transform Coefficients


The continuous w avelet transform (CWT) allow s you to analyze the temporal evolution of the frequency content of a signal or time series. The CWT can be used to detect time-localized events and scale-localized components. When the Fourier transform of a w avelet satisfies certain properties, it is possible to invert the CWT by integrating only over scales. Accordingly, Fourier transform based CWT and inverse CWT algorithms w ith select w avelets enable you to reconstruct a time and scale-localized approximation to a signal. Step 1: Detection of System Anom aly Using the CWT The data analyzed in this example w ere generously provided by the oil company Total. These data are also used in the w avelet coherence example. In that example, the w avelet coherence betw een signals recorded at different sensor locations enables you to detect a system anomaly indicated by the appearance of an oscillatory component. Since it is possible to detect this component by examining data recorded at an individual sensor, w e restrict our attention here to the signal at sensor 1. Analyzing the time series recorded at sensor 1 w ith the CWT reveals the quasi-periodic signal indicative of a system anomaly.

%D e f i n et h es i g n a lt oa n a l y z e . c l e a ra l l ; l o a ds e n s o r 1 ; l o n g =4 0 0 0 ; f i r s t=5 0 0 0 ; l a s t =f i r s t+l o n g 1 ; i n d i c e s=( f i r s t : l a s t ) ; d t=1 ; s i g n a l=s e n s o r 1 ( i n d i c e s ) ; s 1 { 1 }=s i g n a l ; s 1 { 2 }=d t ;

Obtain the CWT over scales 1 to 50 in 0.1 increments using the analytic Morlet w avelet, ' m o r l ' . With the bandw idth and center frequency settings used in the w avelet coherence example, the oscillatory behavior in the sensor data w as observed at approximately scale 15. This scale translates approximately to scale 6 w ith the analytic Morlet w avelet used here. Define the parameters and perform the CWT analysis.

s c a l e s=1 : 0 . 1 : 5 0 ; w n a m e =' m o r l ' ; p a r W A V =6 ; ={ w n a m e , p a r } ;

c w t _ s 1 _ l i n= c w t f t ( s 1 , ' s c a l e s ' , s c a l e s , ' w a v e l e t ' , W A V , ' p l o t ' ) ;

www.mathworks.in/help/wavelet/examples/signal-reconstruction-from-continuous-wavelet-transform-coefficients.html

1/8

4/1/13

Signal Reconstruction from Continuous Wavelet Transform Coefficients - MATLAB & Simulink Example - MathWorks India

The figure show s the CWT decomposition. The middle figure panel in the left column contains a plot of the CWT moduli revealing strong components around scale 6 over approximately the first 2000 points. Another w ay to compute the CWT coefficients is to use the logarithmically-spaced scales provided by the default values.

c w t _ s 1 _ p o w=c w t f t ( s 1 , ' p l o t ' ) ;

The output c w t _ s 1 _ p o wis a structure array w hich contains six fields: the CWT coefficients (c f s ), the vector of scales, the angular frequencies used in the Fourier transform in radians/sample ( o m e g a ), the mean of the signal ( m e a n S I G ), the sampling period ( d t ), and the w avelet ( w a v ). You can use i c w t f tto reconstruct the original signal based on the CWT coefficients.
www.mathworks.in/help/wavelet/examples/signal-reconstruction-from-continuous-wavelet-transform-coefficients.html 2/8

4/1/13

Signal Reconstruction from Continuous Wavelet Transform Coefficients - MATLAB & Simulink Example - MathWorks India

r e c _ s 1 _ p o w=i c w t f t ( c w t _ s 1 _ p o w ) ;

Utilizing a subset of the CWT coefficients, you can reconstruct an approximation to the original signal. The next example illustrates this for the oscillatory component in the sensor 1 data. As a preliminary step, determine the scale containing the greatest percentage of the signal energy.

%C o m p u t et h ee n e r g yd i s t r i b u t i o no v e rs c a l e s . c f s=c w t _ s 1 _ l i n . c f s ; e n e r g y=s u m ( a b s ( c f s ) , 2 ) ; p e r c e n t a g e=1 0 0 * e n e r g y / s u m ( e n e r g y ) ; %D e t e c tt h es c a l eo fg r e a t e s te n e r g y . [ m a x p e r c e n t , m a x S c a l e I D X ]=m a x ( p e r c e n t a g e ) f i g u r e ; p l o t ( p e r c e n t a g e , ' . r ' ) ;h o l do n ; p l o t ( m a x S c a l e I D X , m a x p e r c e n t , ' . k ' , ' M a r k e r s i z e ' , 2 0 ) x l a b e l ( ' I n d i c e so fS c a l e s ' ) y l a b e l ( ' P e r c e n t a g eo fe n e r g y ' ) ; a x i st i g h t g r i d %T h es c a l eo fg r e a t e s te n e r g yi sg i v e nb y : s c a M a x E n e r=s c a l e s ( m a x S c a l e I D X )

m a x p e r c e n t= 0 . 3 5 8 9

m a x S c a l e I D X= 4 1

s c a M a x E n e r= 5

www.mathworks.in/help/wavelet/examples/signal-reconstruction-from-continuous-wavelet-transform-coefficients.html

3/8

4/1/13

Signal Reconstruction from Continuous Wavelet Transform Coefficients - MATLAB & Simulink Example - MathWorks India

Step 2: Reconstruction of System Anom aly Signature in the Tim e Dom ain An interesting use of the analysis-reconstruction process involves modifying the w avelet coefficients betw een analysis and reconstruction. This is routinely done for denoising or compression applications using the discrete w avelet transform. Because the Fourier transform based CWT enables us to efficiently implement an inverse transform, it is possible to extend this selective reconstruction to the CWT. Using this technique, w e can obtain a clearer picture of the system anomaly.

c w t _ a n o m a l y=c w t _ s 1 _ p o w ; %F i n dt h ei n d e xo fl o g a r i t h m i cs c a l ed e t e c t i n gt h e a n o m a l y . [ v a l M i n , a n o m a l y _ i n d e x _ s c a l e s ]=m i n ( a b s ( c w t _ s 1 _ p o w . s c a l e s s c a M a x E n e r ) )

v a l M i n= 0 . 5 1 1 7

a n o m a l y _ i n d e x _ s c a l e s= 4

a n o m a l y _ c f s=c w t _ s 1 _ p o w . c f s ( a n o m a l y _ i n d e x _ s c a l e s , : ) ; n e w C F S=z e r o s ( s i z e ( c w t _ s 1 _ p o w . c f s ) ) ; n e w C F S ( a n o m a l y _ i n d e x _ s c a l e s , : )=a n o m a l y _ c f s ; c w t _ a n o m a l y . c f s=n e w C F S ; %R e c o n s t r u c t i o nf r o mt h em o d i f i e ds t r u c t u r e . a n o m a l y=i c w t f t ( c w t _ a n o m a l y , ' p l o t ' , ' s i g n a l ' , s 1 ) ;


www.mathworks.in/help/wavelet/examples/signal-reconstruction-from-continuous-wavelet-transform-coefficients.html 4/8

4/1/13

Signal Reconstruction from Continuous Wavelet Transform Coefficients - MATLAB & Simulink Example - MathWorks India

In this example only the reconstructed signal is of interest. Plots of the CWT coefficients are not informative because only a single scale contains nonzero coefficients. To obtain a better view of the anomaly, you can perform a horizontal zoom for all axes of the figure.

a x=f i n d o b j ( g c f , ' t y p e ' , ' a x e s ' , ' t a g ' , ' ' ) ; s e t ( a x , ' X l i m ' , [ 2 5 05 0 0 ] ) ;

The selective reconstruction process may be done more directly using the IdxSc name-value pair in the i c w t f tfunction.

i c w t f t ( c w t _ a n o m a l y , ' p l o t ' , ' s i g n a l ' , s 1 , ' I d x S c ' , a n o m a l y _ i n d e x _ s c a l e s ) ;


www.mathworks.in/help/wavelet/examples/signal-reconstruction-from-continuous-wavelet-transform-coefficients.html 5/8

4/1/13

Signal Reconstruction from Continuous Wavelet Transform Coefficients - MATLAB & Simulink Example - MathWorks India

a x=f i n d o b j ( g c f , ' t y p e ' , ' a x e s ' , ' t a g ' , ' ' ) ; s e t ( a x , ' X l i m ' , [ 2 5 05 0 0 ] ) ;

Step 3: A Second Reconstruction of System Anom aly Signature Continuous w avelet analysis greatly facilitates the detection of the quasi-periodic component indicative of a system anomaly. In addition, the inverse CWT algorithm enables you to reconstruct a time and scale-localized approximation to the component based on selected coefficients. The Fourier transform based CWT and inverse CWT algorithms for logarithmic scales are described in Torrence & Compo, 1998. Sun, 2010 proposes an inversion formula for linearly-spaced scales. The algorithm w ith linearly-spaced scales is less efficient than its logarithmically-spaced counterpart because more scales are required for an accurate reconstruction. Nevertheless, this algorithm is experimentally useful and complements the algorithm w ith logarithmically-spaced scales. To end this example, w e illustrate the use of selective linearly-spaced scales for signal approximation.

%F i r s ts t e pf o rb u i l d i n gt h en e ws t r u c t u r ec o r r e s p o n d i n g t ot h ea n o m a l y . c w t _ a n o m a l y=c w t _ s 1 _ l i n ; %C h o o s eav e c t o ro fs c a l e sc e n t e r e do nt h em o s te n e r g e t i c s c a l e . d S c a l e=5 ; a n o m a l y _ i n d e x _ s c a l e s=( m a x S c a l e I D X d S c a l e : m a x S c a l e I D X + d S c a l e ) ; a n o m a l y _ c f s=c w t _ s 1 _ l i n . c f s ( a n o m a l y _ i n d e x _ s c a l e s , : ) ; n e w C F S=z e r o s ( s i z e ( c w t _ s 1 _ l i n . c f s ) ) ; n e w C F S ( a n o m a l y _ i n d e x _ s c a l e s , : )=a n o m a l y _ c f s ; c w t _ a n o m a l y . c f s=n e w C F S ; %R e c o n s t r u c t i o nf r o mt h em o d i f i e ds t r u c t u r e . a n o m a l y=i c w t l i n ( c w t _ a n o m a l y , ' p l o t ' ) ;

www.mathworks.in/help/wavelet/examples/signal-reconstruction-from-continuous-wavelet-transform-coefficients.html

6/8

4/1/13

Signal Reconstruction from Continuous Wavelet Transform Coefficients - MATLAB & Simulink Example - MathWorks India

To get a better view of the anomaly, you can perform a horizontal zoom for all axes of the figure.

a x=f i n d o b j ( g c f , ' t y p e ' , ' a x e s ' , ' t a g ' , ' ' ) ; s e t ( a x , ' X l i m ' , [ 2 5 05 0 0 ] ) ;

The selective reconstruction process may be done more directly using the IdxSc name-value pair in the i c w t l i nfunction.

i c w t l i n ( c w t _ a n o m a l y , ' p l o t ' , ' s i g n a l ' , s 1 , ' I d x S c ' , a n o m a l y _ i n d e x _ s c a l e s ) ; a x=f i n d o b j ( g c f , ' t y p e ' , ' a x e s ' , ' t a g ' , ' ' ) ; s e t ( a x , ' X l i m ' , [ 2 5 05 0 0 ] ) ;

www.mathworks.in/help/wavelet/examples/signal-reconstruction-from-continuous-wavelet-transform-coefficients.html

7/8

4/1/13

Signal Reconstruction from Continuous Wavelet Transform Coefficients - MATLAB & Simulink Example - MathWorks India

Sum m ary This example show s how to use continuous w avelet analysis to detect time and scale-localized components in the time-scale plane. Using Fourier transform based continuous w avelet transform (CWT) and inverse CWT algorithms, the example illustrates how to reconstruct a signal approximation based on scales identified in the analysis. References 1. Torrence, C. & Compo, G.C. A Practical Guide to Wavelet Analysis , Bull. Am. Meteorol. Soc., 79, 61-78, 1998. 2. Sun, W. Convergence of Morlet's Reconstruction Formula, Preprint, 2010.

Was this topic helpful?

Yes

No

Try MATLAB, Simulink, and Other Products


Get trial now

www.mathworks.in/help/wavelet/examples/signal-reconstruction-from-continuous-wavelet-transform-coefficients.html

8/8

You might also like