Wavelet scattering display problem

조회 수: 11 (최근 30일)
Abdelhakim Souidi
Abdelhakim Souidi 2023년 7월 17일
댓글: Anavi Somani 2023년 7월 18일
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
Anavi Somani
Anavi Somani 2023년 7월 18일
Okay, great.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by