Products & Services Solutions Academia Support User Community Company

Illustrated Examples

Fourteen illustrated examples are included in this section, organized as shown:

Example
Equation
Signal Name
MAT-File
Example 1: A Sum of Sines
A sum of sines:

s1(t)
sumsin
Example 2: A Frequency Breakdown
A frequency breakdown:

s2(t)
freqbrk
Example 3: Uniform White Noise
  • A uniform white noise:
      on the interval

  • b1(t)
    whitnois
    Example 4: Colored AR(3) Noise
    A colored AR(3) noise:

    b2(t)
    warma
    Example 5: Polynomial + White Noise
    A polynomial + a white noise:
    on the interval

    s3(t)
    noispol
    Example 6: A Step Signal
    A step signal:

    s4(t)
    wstep
    Example 7: Two Proximal Discontinuities
    Two proximal discontinuities:

    s5(t)
    nearbrk
    Example 8: A Second-Derivative Discontinuity
    A second-derivative discontinuity:

    s6 is f3 sampled at 10-3

    s6(t)
    scddvbrk
    Example 9: A Ramp + White Noise
    A ramp + a white noise:

    s7(t)
    wnoislop
    Example 10: A Ramp + Colored Noise
    A ramp + a colored noise:

    s8(t)
    cnoislop
    Example 11: A Sine + White Noise
    A sine + a white noise:

    s9(t)
    noissin
    Example 12: A Triangle + A Sine
    A triangle + a sine:

    s10(t)
    trsin
    Example 13: A Triangle + A Sine + Noise
    A triangle + a sine + a noise:

    s11(t)
    wntrsin
    Example 14: A Real Electricity Consumption Signal
    A real electricity consumption signal
    --
    leleccum

    Please note that

    The examples include specific comments and feature distinct domains -- for instance, if the level of decomposition is 5,

    Advice to the Reader

    You should follow along and process these examples on your own, using either the graphical interface or the command line functions.

    Use the graphical interface for immediate signal processing. To execute the analyses included in the figures,

    1. To open the Wavelet Toolbox Main Menu, type
    2. Select the Wavelet 1-D menu option to open the Wavelet 1-D tool.
    3. From the Wavelet 1-D tool, choose the FileExample Analysis menu option.
    4. From the dialog box, select the sample analysis in question.

    This triggers the execution of the examples.

    When using the command line, follow the process illustrated in this M-file to conduct calculations:

    About Further Exploration

    Tip 1.   On all figures, visually check that for j = 0, 1, ..., Aj = Aj+1 + Dj+1.

    Tip 2.   Don't forget to change wavelets. Test the shortest ones first.

    Tip 3.   Identify edge effects. They will create problems for a correct analysis. At present, there is no easy way to avoid them perfectly. You can use tools described in the section Dealing with Border Distortion and see also the dwtmode reference page. They should eliminate or greatly reduce these effects.

    Tip 4.   As much as possible, conduct calculations manually to cross-check results with the values in the graphic representations. Manual calculations are possible with the db1 wavelet.

    For the sake of simplicity in the following examples, we use only the haar and db family wavelets, which are the most frequently used wavelets.

    Example 1: A Sum of Sines

    Analyzing wavelet: db3

    Decomposition levels: 5

    The signal is composed of the sum of three sines: slow, medium, and rapid. With regard to the sampling period equal to 1, the periods are approximately 200, 20, and 2 respectively. We should, therefore, see this later period in D1, the medium sine in D4, and the slow sine in A4. The slight differences that can be observed on the decompositions can be attributed to the sampling period. The scale of the approximation charts is 2, 4, or 10 times larger than that of the details. D1 contains primarily the components whose period is situated between 1 and 2 (i.e., the rapid sine), but this period is not visible at the scale that is used for the graph. Zooming in on D1 reveals that each "belly" is composed of 10 oscillations, and can be used to estimate the period. We find that the period is close to 2. D2 is very small. This is also seen in the approximations: the first two resemble one another, since .

    The detail D3 and, to an even greater extent, the detail D4 contain the medium sine. We notice that there is a breakdown between approximations 3 and 4.

    Approximations A1 to A3 can be used to estimate the period of the medium sine. Now, only the slow sine, which appears in A4, remains to be determined. The distance between two successive maximums is equal to 200, which is the period of the slow sine. This latter sine is still visible in A5, but will disappear from the approximation and move into the details at level 8.

    Example 1: A Sum of Sines
    Addressed topics
    • Detecting breakdown points
    • Detecting long-term evolution
    • Identifying pure frequencies
    • The effect of a wavelet on a sine
    • Details and approximations: a signal moves from an approximation to a detail
    • The level at which characteristics appear

    Further exploration
    • Compare with a Fourier analysis.
    • Change the frequencies. Analyze other linear combinations.

    Example 2: A Frequency Breakdown

    Analyzing wavelet: db5

    Decomposition levels: 5

    The signal is formed of a slow sine and a medium sine, on either side of 500. These two sines are not connected in a continuous manner: D1 and D2 can be used to detect this discontinuity. It is localized very precisely: only a small domain around 500 contains large details. This is because the rupture contains the high-frequency part; the frequencies in the rest of the signal are not as high. It should be noted that if we are interested only in identifying the discontinuity, db1 is more useful than db5.

    D3 and D4 contain the medium sine as in the previous analysis. The slow sine appears clearly alone in A5. It is more regular than in the s1 analysis, since db5 is more regular than db3. If the same signal had been analyzed by the Fourier transform, we would not have been able to detect the instant corresponding to the signal's frequency change, whereas it is clearly observable here.

    Example 2: A Frequency Breakdown
    Addressed topics
    • Suppressing signals
    • Detecting long-term evolution

    Further exploration
    • Compare to the signal s1.
    • On a longer signal, select a deeper level of decomposition in such a way that the slow sinusoid appears into the details.
    • Compare with a Fourier analysis.
    • Compare with a windowed Fourier analysis.

    Example 3: Uniform White Noise

    Analyzing wavelet: db3

    Decomposition levels: 5

    At all levels we encounter noise-type signals that are clearly irregular. This is because all the frequencies carry the same energy. The variances, however, decrease regularly between one level and the next as can be seen reading the detail chart (on the right) and the approximations (on the left).

    The variance decreases two-fold between one level and the next, i.e., variance(Dj) = variance(Dj - 1) / 2. Lastly, it should be noted that the details and approximations are not white noise, and that these signals are increasingly interdependent as the resolution decreases. On the other hand, the wavelet coefficients are random, noncorrelated variables. This property is not evident on the reconstructed signals shown here, but it can be guessed at from the representation of the coefficients.

    Example 3: Uniform White Noise
    Addressed topics
    • Processing noise
    • The shapes of the decomposition values
    • The evolution of these shapes according to level; the correlation increases, the variance decreases

    Further exploration
    • Compare the frequencies included in the details with those in the approximations.
    • Study the values of the coefficients and their distribution.
    • On the continuous analysis, identify the chaotic aspect of the colors.
    • Replace the uniform white noise by a Gaussian white noise or other noise.

    Example 4: Colored AR(3) Noise

    Analyzing wavelet: db3

    Decomposition levels: 5

    This figure can be examined in view of Example 3: Uniform White Noise, since we are confronted here with a nonwhite noise whose spectrum is mainly at the higher frequencies. Therefore, it is found primarily in D1, which contains the major portion of the signal. In this situation, which is commonly encountered in practice, the effects of the noise on the analysis decrease considerably more rapidly than in the case of white noise. In A3, A4, and A5, we encounter the same scheme as that in the analysis of (see the table in Example 3: Uniform White Noise), the noise from which is built using linear filtering. ( and are defined explicitly in Illustrated Examples, Examples 3 and 4.)

    Example 4: Colored AR(3) Noise
    Addressed topics
    • Processing noise
    • The relative importance of different details
    • The relative importance of D1 and A1

    Further exploration
    • Compare the detail frequencies with those in the approximations.
    • Compare approximations A3, A4, and A5 with those shown in Example 3: Uniform White Noise.
    • Replace AR(3) with an ARMA (AutoRegressive Moving Average) model noise. For instance,

    • Study an ARIMA (Integrated ARMA) model noise. For instance,

    • Check that each detail can be modeled by an ARMA process.

    Example 5: Polynomial + White Noise

    Analyzing wavelets: db2 and db3

    Decomposition levels: 4

    The purpose of this analysis is to illustrate the property that causes the decomposition by dbN of a p-degree polynomial to produce null details as long as N > p. In this case, p=2 and we examine the first four levels of details for two values of N: one is too small, N=2 on the left, and the other is sufficient, N=3 on the right. The approximations are left out since they differ very little from the signal itself.

    For db2 (on the left), we obtain the decomposition of t2 + b1(t), since the -t + 1 part of the signal is suppressed by the wavelet. In fact, with the exception of level 1, where noise-generated irregularities can be seen, the details for levels 2 to 4 show a periodic form that is very regular, and which increases with the level. This is because the detail for level j takes into account that the fluctuations of the function around its mean value on dyadic intervals are long. The fluctuations are periodic and very large in relation to the details of the noise decomposition.

    On the other hand, for db3 (on the right) we again find the presence of white noise, thus indicating that the polynomial does not come into play in any of the details. The wavelet suppresses the polynomial part and analyzes the noise.

    Example 5: Polynomial + White Noise
    Addressed topics
    • Suppressing signals
    • Compare the results of the processing for the following wavelets: the short db2 and the longer db3.
    • Explain the regularity that is visible in D3 and D4 in the analysis by db2.

    Further exploration
    • Increase noise intensity and repeat the analysis.

    Example 6: A Step Signal

    Analyzing wavelet: db2

    Decomposition levels: 5

    In this case, we are faced with the simplest example of a rupture (i.e., a step). The time instant when the jump occurs is equal to 500. The break is detected at all levels, but it is obviously detected with greater precision in the higher resolutions (levels 1 and 2) than in the lower ones (levels 4 and 5). It is very precisely localized at level 1, where only a very small zone around the jump time can be seen.

    It should be noted that the reconstructed details are primarily composed of the basic wavelet represented in the initial time.

    Furthermore, the rupture is more precisely localized when the wavelet corresponds to a short filter.

    Example 6: A Step Signal
    Addressed topics
    • Detecting breakdown points
    • Suppressing signals
    • Detecting long-term evolution
    • Identifying the range width of the variations of details and approximations

    Further exploration
    • Use the coefficients of the FIR filter associated with the wavelet to check the values of D1.
    • Replace the step by an impulse.
    • Add noise to the signal and repeat the analysis.

    Example 7: Two Proximal Discontinuities

    Analyzing wavelet: db2 and db7

    Decomposition levels: 5

    The signal is formed of two straight lines with identical slopes, extending across a very short plateau. On the initial signal, the plateau is in fact barely visible to the naked eye. Two analyses are thus carried out: one on a well localized wavelet with the short filter (db2, shown on the left side of the figure); and the other on a wavelet having a longer filter (db7, shown on the right side of the figure).

    In both analyses, the plateau is detected clearly. With the exception of a fairly limited domain, D1 is equal to zero. The regularity of the signal in the plateau, however, is clearly distinguished for db2 (for which plateau beginning and end time are distinguished), whereas for db7 both discontinuities are fused and only the entire plateau can be said to be visible.

    This example suggests that the selected wavelets should be associated with short filters to distinguish proximal discontinuities of the first derivative. A look at the other detail levels again shows the lack of precision when detecting at low resolutions. The wavelet filters the straight line and analyzes the discontinuities.

    Example 7: Two Proximal Discontinuities
    Addressed topics
    • Detecting breakdown points

    Further exploration
    • Move the discontinuities closer together and further apart.
    • Add noise to the signal until the rupture is no longer visible.
    • Try using other wavelets, haar for instance.

    Example 8: A Second-Derivative Discontinuity

    Analyzing wavelets: db1 and db4

    Decomposition levels: 2

    This figure shows that the regularity can be an important criterion in selecting a wavelet. The basic function is composed of two exponentials that are connected at 0, and the analyzed signal is the sampling of the continuous function with increments of 10-3. The sampled signal is analyzed using two different wavelets: db1, which is insufficiently regular (shown on the left side of the figure); and db4, which is sufficiently regular (shown on the right side of the figure).

    Looking at the figure on the left, notice that the singularity has not been detected in the extent that the details are equal to 0 at 0. The black areas correspond to very rapid oscillations of the details. These values are equal to the difference between the function and an approximation using a constant function. Close to 0, the slow decrease of the details absolute values followed by a slow increase is due to the fact that the function derivative is zero and continuous at 0. The value of the details is very small (close to 10-3 for db1 and 10-6 for db4), since the signal is very smooth and does not contain any high frequency. This value is even smaller for db4, since the wavelet is more regular than db1.

    However, with db4 (right side of the figure), the discontinuity is well detected; the details are high only close to 0, and are 0 everywhere else. This is the only element that can be derived from the analysis. In this case, as a conclusion, notice that the selected wavelet must be sufficiently regular, which implies a longer filter impulse response to detect the singularity.

    Example 8: A Second-Derivative Discontinuity
    Addressed topics
    • Detecting breakdown points
    • Suppressing signals
    • Identifying a difficult discontinuity
    • Carefully selecting a wavelet to reveal an effect

    Further exploration
    • Calculate the detail values for the Haar wavelet.
    • Be aware of parasitic effects: rapid detail fluctuations may be artifacts.
    • Add noise to the signal until the rupture is no longer visible.

    Example 9: A Ramp + White Noise

    Analyzing wavelet: db3

    Decomposition levels: 6

    The signal is built from a trend plus noise. The trend is a slow linear rise from 0 to 3, up to t=500, and becoming constant afterwards. The noise is a uniform zero-mean white noise, varying between -0.5 and 0.5 (see the analyzed signal b1).

    Looking at the figure, in the chart on the right, we again find the decomposition of noise in the details. In the charts on the left, the approximations form increasingly precise estimates of the ramp with less and less noise. These approximations are quite acceptable from level 3, and the ramp is well reconstructed at level 6.

    We can, therefore, separate the ramp from the noise. Although the noise affects all scales, its effect decreases sufficiently quickly for the low-resolution approximations to restore the ramp. It should also be noted that the breakdown point of the ramp is shown with good precision. This is due to the fact that the ramp is recovered at too low a resolution.

    The uniform noise indicates that the ramp might be best estimated using half sums for the higher and lower portions of the signal. This approach is not applicable for other noises.

    Example 9: A Ramp + White Noise
    Addressed topics
    • Detecting breakdown points
    • Processing noise
    • Detecting long-term evolution
    • Splitting signal components
    • Identifying noises and approximations

    Further exploration
    • Compare with the white noise b1(t) shown in Example 3: Uniform White Noise.
    • Identify the number of levels needed to suppress the noise almost entirely.
    • Change the noise.

    Example 10: A Ramp + Colored Noise

    Analyzing wavelet: db3

    Decomposition levels: 6

    The signal is built in the same manner as in Example 9: A Ramp + White Noise, using a trend plus a noise. The trend is a slow linear increase from 0 to 1, up to t=500. Beyond this time, the value remains constant. The noise is a zero mean AR(3) noise, varying between -3 and 3 (see the analyzed signal b2). The scale of the noise is indeed six times greater than that of the ramp. At first glance, the situation seems a little bit less favorable than in the previous example, in terms of the separation between the ramp and the noise. This is actually a misconception, since the two signal components are more precisely separated in frequency.

    Looking at the figure, the charts on the right show the detail decomposition of the colored noise. The charts on the left show a decomposition that resembles the one in the previous analysis. Starting at level 3, the curves provide satisfactory approximations of the ramp.

    Example 10: A Ramp + Colored Noise
    Addressed topics
    • Detecting breakdown points
    • Processing noise
    • Detecting long-term evolution
    • Splitting signal components

    Further exploration
    • Compare with the s7(t) signal shown in Example 9: A Ramp + White Noise.
    • Identify the number of levels needed to suppress the noise almost entirely.
    • Identify the noise characteristics. Use the coefficients and the command line mode.

    Example 11: A Sine + White Noise

    Analyzing wavelet: db5

    Decomposition levels: 5

    The signal is formed of the sum of two previously analyzed signals: the slow sine with a period close to 200 and the uniform white noise b1. This example is an illustration of the linear property of decompositions: the analysis of the sum of two signals is equal to the sum of analyses.

    The details correspond to those obtained during the decomposition of the white noise.

    The sine is found in the approximation A5. This is a high enough level for the effect of the noise to be negligible in relation to the amplitude of the sine.

    Example 11: A Sine + White Noise
    Addressed topics
    • Processing noise
    • Detecting long-term evolution
    • Splitting signal components
    • Identifying the frequency of a sine

    Further exploration
    • Identify the noise characteristics. Use the coefficients and the command line mode.

    Example 12: A Triangle + A Sine

    Analyzing wavelet: db5

    Decomposition levels: 6

    The signal is the sum of a sine having a period of approximately 20 and of a "triangle".

    D1 and D2 are very small. This suggests that the signal contains no components with periods that are short in relation to the sampling period.

    D3 and especially D4 can be attributed to the sine. The jump of the sine from A3 to D4 is clearly visible.

    The details for the higher levels D5 and D6 are small, especially D5.

    D6 exhibits some edge effects.

    A6 contains the triangle, which includes only low frequencies.

    Example 12: A Triangle + A Sine
    Addressed topics
    • Detecting long-term evolution
    • Splitting signal components
    • Identifying the frequency of a sine

    Further exploration
    • Try using sinusoids whose period is a power of 2.

    Example 13: A Triangle + A Sine + Noise

    Noise Analyzing wavelet: db5

    Decomposition levels: 7

    The signal examined here is the same as the previous signal plus a uniform white noise divided by 3. The analysis can, therefore, be compared to the previous analysis. All differences are due to the presence of the noise.

    D1 and D2 are due to the noise.

    D3 and especially D4 are due to the sine.

    The higher level details are increasingly low, and originate in the noise.

    A7 contains a triangle, although it is not as well reconstructed as in the previous example.

    Example 13: A Triangle + A Sine + Noise
    Addressed topics
    • Detecting long-term evolution
    • Splitting signal components

    Further exploration
    • Increase the amplitude of the noise.
    • Replace the triangle by a polynomial.
    • Replace the white noise by an ARMA noise.

    Example 14: A Real Electricity Consumption Signal

    Analyzing wavelet: db3

    Decomposition levels: 5

    The series presents a peak in the center, followed by two drops, a shallow drop, and then a considerably weaker peak.

    The details for levels 1 and 2 are of the same order of magnitude and give a good expression of the local irregularities caused by the noise. The detail for level 3 presents high values in the beginning and at the end of the main peak, thus allowing us to locate the corresponding drops. The detail D4 shows coarser morphological aspects for the series (i.e., three successive peaks). This fits the shape of the curve remarkably well, and includes the essential signal components for periods of less than 32 time-units. The approximations show this effect clearly: A1 and A2 bear a strong resemblance; A3 forms a reasonably accurate approximation of the original signal. A look at A4, however, shows that a considerable amount of information has been lost.

    In this case, as a conclusion, the multiscale aspect is the most interesting and the most significant feature: the essential components of the electrical signal used to complete the description at 32 time-units (homogeneous to A5) are the components with a period between 8 and 16 time-units.

    Example 14: A Real Electricity Consumption Signal
    Addressed topics
    • Detecting long-term evolution
    • Splitting signal components
    • Detecting breakdown points
    • Multiscale analysis

    Further exploration
    • Try the same analysis on various sections of the signal. Focus on a range other than the [3600:3700] shown here.

    This signal is explored in much greater detail in Case Study: An Electrical Signal.


     Provide feedback about this page 

    Previous page Wavelets in Action: Examples and Case Studies Case Study: An Electrical Signal Next page

    Recommended Products

    Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

     © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS