# Detect abrupt changes in signals with functions "wavedec" and/or "cwt"

11 views (last 30 days)
Sim on 23 Feb 2022
Commented: Sim on 3 Nov 2023
Hi, I read a MATLAB article called "Detecting Discontinuities and Breakdown Points", where both the wavedec (1-D wavelet decomposition) and detcoef (1-D detail coefficients) functions are used to detect abrupt changes of signals. I also checked the cwt (Continuous 1-D wavelet transform) function that might be used to detect abrupt changes of signals (right?). But something is not clear to me - Anyone who is able to reply to one of my two questions? :)
1. Are wavedec (1-D wavelet decomposition) and cwt (Continuous 1-D wavelet transform) somehow related? (Maybe their outputs are somehow related...?!)
2. Can I use the function cwt (Continuous 1-D wavelet transform) to detect abrupt changes in signals?

Abhimenyu on 3 Nov 2023
Hi Sim,
I understand that you have queries regarding the "wavedec" and "cwt" functions from the "Wavelet toolbox" of MATLAB.
Yes, "wavedec" and "cwt" functions are related in the sense that they both use wavelets to decompose a signal into different scales or frequencies. However, they have some differences in how they discretize the scale parameter and how they represent the output.
• The "wavedec" function uses a "discrete wavelet transform (DWT)" that decomposes the signal into different frequency sub-bands or scales using a wavelet basis. The output of the "wavedec function is a set of approximation coefficients (low-frequency components) and detail coefficients (high-frequency components) at different levels of decomposition. Sudden changes in the detail coefficients indicate the presence of sharp transitions or high-frequency components in the signal.
• The "cwt" function uses a "continuous wavelet transform (CWT)" that allows finer discretization of the scale parameter. It examines how a wavelet of varying scales matches a given signal at different positions and returns a matrix of wavelet coefficients as a function of scale and position that can be visualized as a scalogram. The rows of the output matrix represent different scales and the columns represent different time points. Large magnitude coefficients indicate the presence of significant changes at that scale and time point.
Both,the "wavedec" and "cwt" functions can be used to detect abrupt changes or discontinuities in signals. However, they have different characteristics and are suitable for different scenarios.
The "wavedec" function is more suitable for analysing signals with discrete changes or localized abrupt transitions. It provides a multi-resolution decomposition that allows you to analyse the signal at different scales and identify abrupt changes in the detail coefficients. The "cwt"function is more suitable for analysing signals with continuous changes or gradual transitions. It provides a continuous representation of the signal at different scales and time points, allowing you to identify abrupt changes based on the magnitude of the wavelet coefficients.
Please refer to the below mentioned MATLAB documentation links to understand more on "Continuous and discrete wavelet transform", "wavedec" function and "cwt" function respectively:
I hope this helps to resolve the query.
Thanks,
Abhimenyu
Sim on 3 Nov 2023
Thanks a lot @Abhimenyu, very kind! :-) Yes, it helps :-)