How to plot this kind of figure?

37 次查看(过去 30 天)
Hello,
I would like to reproduce these figures that I found in a scientific article. They are just below.
The values to generate the waves are not important for me, it's just an illustration.

采纳的回答

Umeshraja
Umeshraja 2024-11-21,5:08
I understand that you're looking to illustrate wavelets between two lines that pass through the origin. The goal is to determine the lengths of the long and short wavelets and plot their shifted versions. Below is a sample script that demonstrates how to draw a Morlet wavelet between lines with slopes of 5 and 1, and how to shift these wavelets to y = 4 and y = 6.
close all;
% Define the slopes of the two lines
slope1 = 5;
slope2 = 1;
% Define a range for the x-values in the first quadrant (positive values)
x = 0:0.01:10;
% Calculate the corresponding y-values for each line
y1 = slope1 * x;
y2 = slope2 * x;
% Calculate the x-values where the lines intersect y = 4 and y = 6
xs1 = 4 / slope1;
xs2 = 4 / slope2;
WaveletLengthShort=xs2-xs1;
xl1 = 6 / slope1;
xl2 = 6 / slope2;
WaveletLengthLong=xl2-xl1;
w0 = 2;
t=-3:0.01:9 ;
t_long = -WaveletLengthLong*0.5:0.01:WaveletLengthLong*0.5;
sigma1 = 0.75; % Standard deviation of the Gaussian window
% Morlet Wavelet (Real part only)
morlet_wavelet = (pi^(-0.25)) * exp(2i * pi * w0 * t_long) .* exp(-t_long.^2 / (2 * sigma1^2));
t_shifted1 = t_long +WaveletLengthLong*0.5+xl1;
y_shifted1 = 6 * ones(size(t));
indices1 = (t >= min(t_shifted1) & t <= max(t_shifted1) );
y_shifted1(indices1) = y_shifted1(indices1) + (morlet_wavelet);
% Create a shorter second wavelet
t_short = -WaveletLengthShort*0.5:0.01:WaveletLengthShort*0.5; % Shorter time vector
sigma2=0.5;
morlet_wavelet_short = 0.8*(pi^(-0.25)) * exp(2i * pi * w0 * t_short) .* exp(-t_short.^2 / (2 * sigma2^2));
% Shift the second wavelet to the right by 1 unit and plot at y = 1
t_shifted2 = t_short + WaveletLengthShort*0.5+xs1;
y_shifted2 = 4 * ones(size(t));
% Find indices in the original time vector that match the shifted short wavelet
indices2 = (t >= min(t_shifted2) & t <= max(t_shifted2));
y_shifted2(indices2) = y_shifted2(indices2) + (morlet_wavelet_short);
figure;
plot(x, y1, 'k');
hold on;
plot(x, y2, 'k');
plot(t, real(y_shifted1), 'b');
plot(t, real(y_shifted2), 'r');
hold off;
ylim([0 8])
xlim([0 8])
Adjust any parameters as needed to fit your specific requirements.
  1 个评论
Gaétan Andriano
Gaétan Andriano about 16 hours 前
it was exactly what I wanted to do! Thank you a lot!
Best rergards, Gaétan

请先登录,再进行评论。

更多回答(0 个)

类别

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

Community Treasure Hunt

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

Start Hunting!

Translated by