complex morlet wavelet frequency representation

12 次查看(过去 30 天)
Hi,
I am performing time-frequency analysis using a complex Morlet wavelet. My approach involves: Taking the FFT of my signal, utilizing the frequency resolution of a complex Morlet wavelet with a center frequency of 1 Hz and sigma = 0.7, multiplying the FFT of my signal by the FFT of the complex Morlet wavelet, and applying the inverse FFT (ifft) to obtain the power and phase information.
However, I want to restrict my analysis to the frequency range of 0.1 Hz to 20 Hz, with increments of 0.1 Hz. How can I incorporate this specific frequency range into the FFT representation of the Morlet wavelet? Alternatively, would using a convolution-based technique be more suitable for this purpose? Any help on how to implement this efficiently in MATLAB would be greatly appreciated.

回答(1 个)

Parag
Parag 2025-4-9
Hi @Shamim,
The code below performs a comparative time-frequency analysis using complex Morlet wavelets. It illustrates two methods—FFT-based convolution and time-domain convolution—to extract how power varies across time and frequency in a synthetic multi-component signal.
A signal is constructed using known sinusoidal components combined with noise to simulate real-world behavior. A Morlet wavelet is generated for each frequency from 0.1 Hz to 20 Hz. In the first method, both signal and wavelet are transformed via FFT, multiplied in the frequency domain, and inverted to yield power over time. In the second method, the signal is directly convolved with each wavelet using MATLAB’s conv function.
Both resulting time-frequency representations (tf for FFT-based, tf_conv for time-domain) are visualized using imagesc, allowing direct comparison.
% Sampling parameters
srate = 100; % Sampling rate in Hz
duration = 10; % Duration in seconds
t = 0:1/srate:duration; % Time vector
n = length(t);
% Generate random signal with multiple components
rng(1); % For reproducibility
% Components: sinusoids + random noise
signal = ...
0.7 * sin(2*pi*2*t) + ... % 2 Hz
0.5 * sin(2*pi*10*t + pi/4) + ... % 10 Hz with phase shift
0.3 * sin(2*pi*15*t) + ... % 15 Hz
0.2 * randn(size(t)); % White noise
% Optional: visualize the signal
figure;
plot(t, signal);
xlabel('Time (s)');
ylabel('Amplitude');
title('Randomly Initialized Synthetic Signal');
% Define frequency range
freqs = 0.1:0.1:20; % in Hz
% Define time vector long enough to capture low frequencies
srate = 100; % sampling rate in Hz
t = -5:1/srate:5; % symmetric time vector (adjust as needed)
nTime = length(t);
nFreq = length(freqs);
% FFT of signal
nData = length(signal);
signalFFT = fft(signal, nTime); % Zero-pad to match wavelet size
% Output matrix
tf = zeros(nFreq, nTime); % stores time-frequency representation
% Loop through frequencies
for fi = 1:nFreq
f = freqs(fi);
sigma_f = 0.7;
s = sigma_f / (2*pi*f); % standard deviation in time
% Create complex Morlet wavelet
wavelet = exp(2*1i*pi*f*t) .* exp(-t.^2/(2*s^2));
% FFT of wavelet
waveletFFT = fft(wavelet, nTime);
waveletFFT = waveletFFT / max(abs(waveletFFT)); % normalize
% Convolve via frequency domain multiplication
convolutionResult = ifft(waveletFFT .* signalFFT, nTime);
% Store power or phase
tf(fi, :) = abs(convolutionResult).^2; % or angle(...) for phase
end
% Time-frequency representation is stored in tf(frequency, time)
% Frequencies for analysis
freqs = 0.1:0.1:20; % Frequency range (Hz)
nFreq = length(freqs);
% Morlet wavelet parameters
sigma_f = 0.7;
tf_conv = zeros(nFreq, n); % Time-frequency result (conv)
% Loop over each frequency
for fi = 1:nFreq
f = freqs(fi);
s = sigma_f / (2*pi*f); % std dev in time domain
% Define time for wavelet (ensure it's long enough)
t_wavelet = -5:1/srate:5;
% Create complex Morlet wavelet
wavelet = exp(2*1i*pi*f*t_wavelet) .* exp(-t_wavelet.^2/(2*s^2));
% Time-domain convolution
convResult = conv(signal, wavelet, 'same');
% Store power
tf_conv(fi, :) = abs(convResult).^2;
end
% Time-frequency plot - Time-Domain Convolution
figure;
imagesc(t, freqs, tf_conv);
axis xy;
xlabel('Time (s)');
ylabel('Frequency (Hz)');
title('Time-Frequency Power (Time-Domain Convolution)');
colormap jet;
colorbar;
% If FFT-based
:
figure;
imagesc(t, freqs, tf);
axis xy;
xlabel('Time (s)');
ylabel('Frequency (Hz)');
title('Time-Frequency Power (FFT-Based Convolution)');
colormap jet;
colorbar;
Please refer to the MATLAB documentation below for information on Morlet Wavelet:
I hope this is beneficial!
  1 个评论
Shamim
Shamim 2025-4-10
Thank you so much for your help and explanantion.
That was so helpful. I just have a few questions regarding your code to just help me better understand it.
My first question is how should we account for centeral frequency? As I want to apply an algorithm that a paper suggested in their methodology for my analyses and they said that they used a complex Morlet wavelet with cental frequency of 1 Hz and sigma of 0.7 and applied this wavelet in the frequency range of 0.1 to 20 Hz with 0.1 Hz increments. My question is should we use the centeral frequency value at any point in the code?
My next question is for the part that you padded yout fft values equal to the length of time, should it be padded to (lenght of the signal)+ (length of the wavelet) -1 (if found this formual for padding the fft of signal and fft of wavelet in this paper https://www.sciencedirect.com/science/article/abs/pii/S1053811919304409)?
And my last question is why do we need to devide the sigma by the 2*pi*f (as you mentioned in your code :s = sigma_f / (2*pi*f); % standard deviation in time)?
I would truly appreciate your answers and help with these questions as they help me to better understand the code.
Thank you very much.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Continuous Wavelet Transforms 的更多信息

产品


版本

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by