extracting data from wavelet

1 view (last 30 days)
devi r nair
devi r nair on 7 Jan 2021
Answered: Suraj Kumar on 2 Apr 2025
can someone pls help me with the code to extract variance data from wavelet plot in matlab? like how to extract X variation data correspondig to a Y axis value from a wavelet.
thank you

Answers (1)

Suraj Kumar
Suraj Kumar on 2 Apr 2025
Hi Devi,
To extract variance data from a wavelet plot in MATLAB, we can start by computing the Continuous Wavelet Transform (CWT) of your signal using the `cwt` function. This function provides us with the wavelet coefficients and their corresponding frequencies or scales. Once we have these coefficients, we can identify the specific frequency that corresponds to the Y-axis value.
t = 0:0.001:1;
signal = sin(2*pi*50*t) + sin(2*pi*120*t);
[coefficients, frequencies] = cwt(signal, 'amor', 1/t(2));
desiredFrequency = 50;
[~, freqIndex] = min(abs(frequencies - desiredFrequency));
desiredCoefficients = coefficients(freqIndex, :);
After identifying the relevant coefficients, we can calculate their variance using MATLAB's `var` function. This variance represents the variation in your signal at the specified frequency.
varianceValue = var(desiredCoefficients);
disp(['Variance at frequency ' num2str(desiredFrequency) ' Hz: ' num2str(varianceValue)]);
Variance at frequency 50 Hz: 0.9514
To learn more about the functions 'cwt' and 'var' in MATLAB, please refer to the following documentation links:

Categories

Find more on Wavelet Toolbox in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!