The Continuous Wavelet Transform (CWT) in MATLAB allows for the analysis of localized variations of power within a time series by transforming it into the wavelet domain.
% Example of Continuous Wavelet Transform (CWT) in MATLAB
% Load a sample signal
load noisdop; % This is a built-in MATLAB example signal
% Perform the CWT
[wt,f] = cwt(doppler, 'amor', 1:64);
% Plot the CWT
figure;
cwtplot(wt,f);
title('Continuous Wavelet Transform of Doppler Signal');
Understanding Wavelet Transforms
What are Wavelet Transforms?
Wavelet transforms are mathematical tools that provide a time-frequency representation of signals, capturing both frequency and temporal changes. Unlike traditional Fourier transforms which expose frequency content while ignoring the time localization of those frequencies, wavelet transforms decompose signals into components at various frequency scales, offering insights into localized frequency content.
Key Terms and Concepts
Wavelets are small, oscillating functions that can be used to analyze the local characteristics of signals. Typical types of wavelets include the Haar wavelet, Morlet wavelet, and Daubechies wavelet, each possessing unique properties suitable for different applications.
Scalograms are visual representations of the wavelet transform, conveying how a signal's frequency content varies over time. In essence, scalograms serve as a powerful visualization tool to interpret complex signals.
Mother Wavelet is the fundamental wavelet used to generate scales for the transform. The choice of mother wavelet significantly influences how well the CWT can capture specific features of the signal.

Getting Started with CWT in MATLAB
Setting Up the Environment
Before diving into CWT in MATLAB, ensure you have the Wavelet Toolbox installed. This toolbox provides the necessary functions for performing wavelet analysis, including the `cwt` command. You can check for the toolbox by navigating to your MATLAB environment and typing `ver`.
Basic Syntax of cwt Command
The basic syntax for the `cwt` command in MATLAB is quite straightforward:
CWT = cwt(signal, wavelet, scales);
Signal refers to your input data, wavelet denotes the selected mother wavelet, and scales indicates the specific scales or frequencies you wish to analyze.
Example of a Simple CWT Command
To get started, here is a basic example of using the `cwt` command:
% Basic CWT command example
cwt(signal);
This command will compute the CWT of the input signal using the default mother wavelet.

Applying CWT in MATLAB
Step-by-Step Process
Step 1: Importing or Creating a Signal Before applying CWT, you need a signal to work with. You can either import a dataset or create a synthetic signal for testing. Below is an example of creating a simple sine wave signal composed of two frequencies:
t = 0:0.001:1; % time vector
signal = sin(2 * pi * 50 * t) + sin(2 * pi * 120 * t); % signal
This generates a signal containing two sine waves with frequencies of 50 Hz and 120 Hz.
Step 2: Choosing a Mother Wavelet Choosing an appropriate mother wavelet is essential for meaningful analysis. Commonly used wavelets include the Morlet wavelet, which is well-suited for frequency identification, and the Mexican Hat wavelet, known for edge detection in signals. To specify a mother wavelet in your command, simply include its name:
% Using Morlet wavelet
cwt(signal, 'morlet');
Step 3: Executing the CWT Once your signal and wavelet are defined, executing the CWT is straightforward. Below is an example of how to execute the command and visualize the result using `imagesc`, which provides a scalable representation:
% Plotting CWT
[C, F] = cwt(signal, 'morlet');
imagesc(t, F, abs(C));
This command plots the absolute values of the CWT coefficients, allowing for intuitive interpretation of how the signal's frequency content evolves over time.
Visualizing the Results
Visualization is critical to understanding the output of a CWT analysis. Using MATLAB’s plotting functions, you can customize your plots to enhance clarity:
- Use `title`, `xlabel`, and `ylabel` to provide additional context.
- Experiment with color maps (e.g., `colormap(jet)`) for visual appeal.

Interpreting CWT Results
Understanding the Scalogram
The scalogram visually represents the wavelet coefficients as a function of time and scale. Darker regions often indicate higher energy at corresponding scales and times. By interpreting these visual cues, you can identify patterns and key features in your signal.
Identifying Features in CWT
CWT enables clear identification of significant features, such as peaks and transient behaviors in the signal. The time-frequency representation can help pinpoint phenomena like anomalies in biomedical signals or distinctive events in audio data. Analyzing the scalogram allows you to set thresholds and extract meaningful insights.

Common Use Cases for CWT in MATLAB
Audio Signal Processing
A notable application of CWT in MATLAB is audio signal analysis. For instance, you might utilize CWT to analyze a musical signal's tonal structure over time, enabling the identification of various instrument contributions. By segmenting audio into different time frames, one can extract notes, chords, and dynamics.
Biomedical Applications
CWT also plays a critical role in biomedical signal processing, particularly for analyzing signals such as ECG or EEG. By applying CWT, you can extract features such as heartbeats or brain waves, providing vital insights into patient conditions. Here’s a basic code snippet you might use for an ECG signal analysis:
% Assume ecg_signal is your preloaded ECG data
[C, F] = cwt(ecg_signal, 'morl');
imagesc(time_vector, F, abs(C));
Engineering and Structural Health Monitoring
In engineering disciplines, CWT assists in detecting structural weaknesses by analyzing vibrational data. It can help identify stress points or resonance frequencies in structures such as bridges or buildings. By applying CWT, engineers can monitor real-time data for maintenance purposes.

Advanced CWT Techniques in MATLAB
Multiresolution Analysis (MRA)
Multiresolution Analysis (MRA) expands on CWT by allowing analysts to examine signals at different resolutions. MRA can reveal details about both coarse and fine features of a signal, making it suitable for identifying trends over time. Implementing MRA in MATLAB requires integrating both CWT and threshold settings for detail extraction.
Wavelet Coefficients and Feature Extraction
Wavelet coefficients are pivotal to feature extraction, providing a way to compress data while retaining significant information. After performing the CWT, you can use the coefficients to derive statistical measures, aiding in predictive modeling:
% Feature extraction using wavelet coefficients
[C, L] = wavedec(signal, N, 'haar');
This code extracts significant features over N decomposition levels, which can be further analyzed for machine learning application.

Conclusion
The Continuous Wavelet Transform (CWT) in MATLAB represents a powerful analytical tool for signal processing. Whether you are working with audio signals, biomedical data, or structural engineering, understanding and implementing CWT can unlock valuable insights. Experiment with different wavelets and signal types to discover the full range of CWT's capabilities.

FAQs
What is the difference between CWT and DWT?
The Continuous Wavelet Transform (CWT) provides a highly detailed representation in both time and frequency domains without losing information, while the Discrete Wavelet Transform (DWT) decomposes signals at discrete intervals, leading to less information but a faster computation.
How do I choose the right mother wavelet?
Choosing a mother wavelet depends on your signal characteristics and the features you intend to analyze. For temporal data, Morlet is often suitable, while for sharp signal edges, the Haar wavelet is preferred.
Can I use CWT for 2D data?
Yes, CWT can be extended to 2D data (images); however, specific techniques and modifications apply. Two-dimensional wavelet transforms can analyze and process image data significantly more complexly than temporal signals.