Clear Filters
Clear Filters

How to plot scales versus time in continuous wavelet transform?

3 views (last 30 days)
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.

Answers (1)

albara
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
  1 Comment
Navid
Navid on 20 Jan 2024
Hello,
I am reporting an issue I faced while using the Morse wavelet. I received an error message stating, "Error when using surf. Data dimensions must agree." I would appreciate your assistance in resolving this problem and any guidance you can offer. Thank you for your time and attention to this matter.
Best regards,
Navid

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!