## Matching Pursuit Using Wavelet Analyzer App

### Matching Pursuit 1-D Interactive Tool

You can perform basic, orthogonal, and weak orthogonal matching pursuit using the Wavelet
Analyzer app. To access the **Matching Pursuit 1-D**, enter
`waveletAnalyzer`

at the MATLAB^{®} command prompt.

Click **Matching Pursuit 1-D**.

To demonstrate the **Matching Pursuit 1-D** tool, select
**File** —> **Example** —>
**Cusp signal**.

In the upper left corner, you see the plot of the signal with the matching pursuit approximation superimposed.

Underneath the plot, you see the relative errors using the L1, L2, and L-infinity norms.

The maximum relative error in a given norm is

$$100\frac{\left|\right|R\left|\right|}{\left|\right|Y\left|\right|},$$

where || || denotes the specified norm, *R* is
the residual vector at each iteration in the matching pursuit algorithm,
and *Y* is the signal.

In the middle panel on the left is the plot of the final residual vector after the matching pursuit algorithm terminates.

The bottom left panel displays the percentage of retained signal energy (L2 norm) and the relative error percentages for the L1, L2, and L-infinity norms over the algorithm iterations.

In the top middle panel of the **Matching Pursuit 1-D** tool,
you see the indices of the selected coefficients from the subdictionaries.

The left vertical axis shows the name of the subdictionary. The right vertical axis gives the ratio of selected vectors to the total number of vectors in the subdictionary. The location of the vertical bars along the horizontal axis gives the relative positions of the selected vectors in the subdictionaries.

More detailed information on selected components is available
by clicking **More on Components** in the bottom
right panel.

The bottom middle panel displays the superposition of selected vectors from the subdictionaries.

This
plot enables you to assess the relative contribution of the subdictionaries
to the signal approximation. In this example, you can see that the
cosine and DCT subdictionaries contribute significantly to the approximation
of the slowly-varying portions of the signal. The Daubechies least
asymmetric wavelet with 4 vanishing moments (`sym4`

)
enables the matching pursuit to sparsely represent the cusp around
index 700.

In the top right panel of the **Matching Pursuit 1-D** tool,
you see the dictionary used in the analysis.

You have the ability to add or delete subdictionaries with **Add
Component** and **Del Component**.

The next panel contains the algorithm stopping rules.

**Max. Iterations**— This controls the number of iterations of the greedy matching pursuit algorithm. The value is equal to the number of expansion coefficients (vectors) used in the approximation. The utility of matching pursuit is that you can approximate many real-world signals efficiently with far fewer vectors than needed to span the signal space.**Max Relative Error**— Specifies the stopping criterion based on the maximum relative error. Choose one of`None`

,`L2 norm`

,`L1 norm`

, or`Linf norm`

.The maximum relative error in a given norm is

$$100\frac{\left|\right|R\left|\right|}{\left|\right|Y\left|\right|},$$

where || || denotes the specified norm,

*R*is the residual vector at each iteration in the matching pursuit algorithm, and*Y*is the signal.

In the next panel you select the algorithm used in the matching
pursuit. Choose one of `Basic MP`

for basic
matching pursuit, `Orthogonal MP`

for orthogonal
matching pursuit, and `Weak MP`

for weak
orthogonal matching pursuit. See Matching Pursuit Algorithms for a brief description of these
algorithms.

In the **Display Parameters** panel, you can
control how the progress of the matching pursuit is displayed.

Select one of

`Final Plot`

— Plots the result of matching pursuit only after the algorithm terminates.`Stepwise`

— Updates the result every N iterations where N is a positive integer. If you select`Stepwise`

, the**Display every iterations**item becomes visible. Select the number of iterations from the drop down menu. You are prompted to step through the algorithm with the**Next**or**Final Plot**.`Movie`

— Updates the result every N iterations where N is a positive integer in a continuous manner. If you select`Movie`

, the**Display every iterations**item becomes visible. Select the number of iterations from the drop down menu. Click**Continue**to step through the algorithm as a movie, which continues until the algorithm terminates. Click**Pause**to pause the algorithm, or**Final Plot**to update only at the termination of the algorithm.

After you obtain a matching pursuit of a signal, use

to obtain detailed interactive plots and information on the selected dictionary atoms and the final residual vector.

Click **More on Components**.

From the above figure, you can see that while the DCT and cosine subdictionaries contribute energy across the extent of the signal, the wavelet and wavelet packet contributions are localized at the cusp around sample 700. This result is expected because wavelets and wavelet packets excel at sparsely representing abrupt changes in a signal or image.

Change the **Display** to the `Coefficients`

view.

The **Selection of Coefficients** panel enables
you to selectively sort and display contributions to the signal approximation
by the various subdictionaries.

Under **Selection parameters**, choose ```
By
Family
```

and `sym4 — lev5`

.
Click **Select**

From the preceding operation, you see that the wavelet packet contributes to the approximation of the cusp, but does not contribute significantly to the global approximation.

Choose `dct`

and click **Select**.

The DCT basis contributes significantly to the global approximation of the signal but the smooth DCT basis vectors are not able to sparsely represent the cusp.

Selecting **More on Residuals** on the **Matching Pursuit
1-D** tool allows you to examine the residual vector, a histogram of
the residuals, a cumulative histogram, the estimated autocorrelation sequence, and
the magnitude-squared discrete Fourier transform.

You can control which plots are displayed and the appearance of the histogram by the options in the right panel.

### Interactive Matching Pursuit of Electricity Consumption Data

This example shows how to perform an interactive matching pursuit of electricity consumption data collected over a 24-hour period.

Load the electricity consumption signals in the workspace. Select the data for the 32nd day for further matching pursuit.

```
load elec35_nor;
x = signals(32,:);
```

To start the app, enter `waveletAnalyzer`

at the
MATLAB command prompt.

Click the **Matching Pursuit 1-D** tool.

Select **File** —> **Import
Signal from Workspace**

Load `x`

.

Construct the following matching pursuit dictionary.

In the **Algorithm Stopping Rules** panel,
set **Max. Iterations** to 30.

Select `Orthogonal MP`

to use
orthogonal matching pursuit.

Click **Approximate**.