How to plot scales versus time in continuous wavelet transform?
11 views (last 30 days)
Show older comments
Dear all, I have data set over time. I used continuous wavelet transform as follows:
C = cwt (signal,1:200,'bior3.3','plot')
How can I plot the scales against time (instead of scales against the number of data)?
Sincerely.
0 Comments
Answers (1)
albara
on 27 Apr 2023
Edited: albara
on 27 Apr 2023
To plot the Continuous Wavelet Transform (CWT) coefficients with scales against time instead of the number of data points, you can create a time vector that corresponds to your signal and use it on the x-axis of your plot. Here's an example:
% Example signal (Replace this with your actual data)
signal = randn(1, 1000);
% Sampling frequency (Replace this with the correct value for your data)
fs = 1000;
% Calculate the time vector
N = length(signal);
t = (0:N-1) / fs;
% Compute the CWT coefficients
scales = 1:200;
wname = 'bior3.3';
C = cwt(signal, scales, wname);
% Create a meshgrid for the time and scales
[T, S] = meshgrid(t, scales);
% Plot the CWT coefficients with time and scales
figure;
surf(T, S, abs(C), 'EdgeColor', 'none');
view(0, 90); % Set the view to 2D
xlabel('Time (s)');
ylabel('Scale');
title('Continuous Wavelet Transform (CWT) Coefficients');
colorbar;
This code should generate a 2D plot of the CWT coefficients with the correct time and scale axes based on your signal and sampling frequency.
Important: There may be some mistakes in this answer Experts can tell if there are any mistakes
See Also
Categories
Find more on Continuous Wavelet Transforms 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!