Wavelet scattering display problem

2 次查看(过去 30 天)
Dear All,
I have a problem with Scattergram, when I use wavelet scattering coefficients to plot the scattergram it displays like this:
but when I store the scattergam in data variable and try to plot the contour of it, the image is reversed and I lost the axis (time, frequency) as the following picture:
Here is the code and the signal :
fs =2000;
sf = waveletScattering('SignalLength',numel(pcg),...
'SamplingFrequency',fs);
[S,U] = scatteringTransform(sf,pcg);
% Normal case
figure,
scattergram(sf,U,'FilterBank',1);
% Abnormal case
img = scattergram(sf,U,'FilterBank',1);
contour(img)
if could anyone help with this problem, I'll appreciate it

采纳的回答

Anavi Somani
Anavi Somani 2023-7-18
Hi,
The issue you're facing with the reversed scattergram image and the lost axis when plotting the contour could be due to the difference in the default coordinate system used by `scattergram` and `contour` functions in MATLAB.
The `scattergram` function plots the scattergram with time on the x-axis and frequency on the y-axis by default. However, the `contour` function assumes that the first dimension of the image corresponds to the y-axis and the second dimension corresponds to the x-axis.
To address this issue and correctly plot the contour with the appropriate axis labels, you can modify the code as follows:
fs = 2000;
sf = waveletScattering('SignalLength', numel(pcg), 'SamplingFrequency', fs);
[S, U] = scatteringTransform(sf, pcg);
% Normal case
figure
scattergram(sf, U, 'FilterBank', 1);
% Abnormal case
img = scattergram(sf, U, 'FilterBank', 1);
contour(flipud(img), 'XData', sf{1}.time, 'YData', sf{1}.log2Scales)
xlabel('Time')
ylabel('Frequency')
In the modified code, the `flipud` function is used to flip the image vertically, aligning it with the expected orientation for the `contour` function. Additionally, the `XData` and `YData` parameters are provided to specify the correct axis labels for the contour plot.
By incorporating these changes, you should be able to plot the contour of the scattergram with the correct orientation and axis labels.
Hope it helps.
  2 个评论
Abdelhakim Souidi
Abdelhakim Souidi 2023-7-18
Thank you for replying, indeed this function flip the image vertically.
I come up with other solution, it just based on picking up the centerfrequencies
t1 = linspace(0,size(pcg,1)/fs,size(img,2));
F =centerFrequencies(sf);
f = F{1,1};
figure,
contour(t1,f,img);
thank you

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Contour Plots 的更多信息

产品


版本

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by