Coding wavelets the easy way

Nonlinear Approximation



Here we show that setting a large number of wavelet coefficients to 0 does not significantly alter the signal when its has isolated singularities.

To do so, we write a function named thresholdValue with syntax
t = thresholdValue(WT,numEl)
which, given a wavelet transform WT and a number of elements numEl, sorts the absolute value of all the details by descending order, and returns the value in position numEl in this list. Consult the help on the Matlab size and sort function.

The second function uses the threshold value t to set to 0 all details in a wavelet transform whose absolute value is below t. The syntax of the function is
WT = threshold(WT,t)
Consult the help on the Matlab find function.

Finally, write a test script that load PieceRegSig and Daub4, and for 6 scales, keeps a number of details that is a tenth of the length of a signal, and computes the inverse wavelet transform. Plot the original signal in blue against the approximated one in red.
Consult the help on the Matlab hold function for superposing multiple plots.
Try different values for the scale and NumEl variables.