[solved] difference between 2 spectrograms

16 ビュー (過去 30 日間)
bryan
bryan 2019 年 9 月 25 日
コメント済み: bryan 2020 年 2 月 28 日
Hello,
Here is the situation:
I have a dynamic system equipped with a vibration sensor.
this system has 2 configurations; I have 1 record of 10 minutes in each configuration
I plot spectrogram for each. So far, everything is fine
[s,f,t]=spectrogramspectrogram(data,hamming(wdw),overlap,[],10240);
[s2,f,t]=spectrogram(data2,hamming(wdw),overlap,[],10240);
Now I want to compare (make a difference) of these spectrograms, but
I can do s-s2, but before
I can't plot back the spectrogram from s
I tried several thing such as
im=imagesc(h/1000,(t/60),(abs((s')))) ; % tested with imag real and with image
colorbar
ylabel('Time (mins)');
xlabel('Frequency (kHz)');
but the result is different from
spectrogram(data,hamming(wdw),overlap,[],10240);
thank you for your answer

採用された回答

bryan
bryan 2019 年 9 月 25 日
編集済み: bryan 2019 年 9 月 25 日
Hello,
thank you for your answer, this is great help
here is the result
Sans titre.png
this is the best result I got so far. :D
some possible improvments
-the last time index is deleted
-Z data is different (but I will make comparisons, si not very important)
-the pscolor give a flat image, when spectrogram give a 3D I can rotate
  1 件のコメント
Bjorn Gustavsson
Bjorn Gustavsson 2019 年 9 月 25 日
For the last point you can simply change pcolor to surf. For the point about the colour-scale, it might be that the top plot is something like:
pcolor(f,t,10*log10(abs(s)/max(abs(s(:))))), shading flat
that is display the spectrogram in dB relative to the strongest component.

サインインしてコメントする。

その他の回答 (5 件)

Bjorn Gustavsson
Bjorn Gustavsson 2019 年 9 月 25 日
Spectrogram called without input arguments seems to plot log10 of the power. try this:
im = pcolor(h/1000,(t/60),log10(abs((s'))));
shading flat
colorbar
ylabel('Time (mins)');
xlabel('Frequency (kHz)');
HTH

bryan
bryan 2019 年 9 月 25 日
thank you again
surf work fine (I think I got a parenthesis problem)
I will try this suggestion for amplitude
but for the time, I have a synchronisation problem visible in the rounded areaSans titre.png
  1 件のコメント
Bjorn Gustavsson
Bjorn Gustavsson 2019 年 9 月 25 日
That has something to do with what your red curve is, and not that much with the spectrogram-plot, I think.
A completely different question is if you need this spectral resolution - you might get more useful results if you reduce the length of your window. That would reduce the frequency-resolution but will give you improved time-resolution.

サインインしてコメントする。


bryan
bryan 2019 年 10 月 2 日
Thank you for your answer, and sorry for the late reply
  • for the problem of Z difference, I searched in pspectrogram.m, and it seems to be
hndl = surf(t, f, 10*log10(abs(Pxx)+eps),'EdgeColor','none');
so I tried it (without eps), and I noticed the original spectrogam plot removes low frequency, so this also explain why the scale is different, because the low frequencies are high on my data.
I will have a look at the time synchro next time

bryan
bryan 2019 年 10 月 25 日
編集済み: bryan 2019 年 10 月 28 日
Hello,
for the Z resolution problem (yes it's a late reply), I solved by myself
I noticed surf function doesn't plot the last Y value
So I added a dummy column on the matrix, a dummy element on the Y vector and now I see as much lines in the ploted surface as it actually has
  1 件のコメント
Bjorn Gustavsson
Bjorn Gustavsson 2019 年 10 月 25 日
Yes, that is true, but the "red curve" of yours varies at shorter time-scales than your time-resolution of your spectrogram - to try to resolve that you could try to run spectrogram with a shorter window, wdw, and overlap (this will reduce the spectral resolution, but you have plenty of that already.)
HTH

サインインしてコメントする。


bryan
bryan 2019 年 10 月 28 日
yes, well this is another issue.
this is easy to change, exept I face memory problems (there are lots of data).I focus on the stabilized areas for the moment
  2 件のコメント
Bjorn Gustavsson
Bjorn Gustavsson 2019 年 10 月 28 日
You will not get more data in your spectrogram if you increase the time-resolution and reduce the spectral resolution - this is Heisenberg! As your spectrogram looks now you have "too high" spectral resolution and too low temporal resolution.
bryan
bryan 2020 年 2 月 28 日
you are right, nfft=528 is enaught

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeTime-Frequency Analysis についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by