MATLAB Answers

James
0

How to quantify spectrogram comparison

Asked by James
on 5 Jan 2017
Latest activity Answered by Ignas A.
on 19 Nov 2018
Given: Two spectrogram plots (spec1.png and spec2.png attached)
Looking for: A method to quantify the difference between the two spectrograms
Purpose: Fault detection and fault severity classification
Previously tried: Substracting the two spectrograms on a point by point basis using: (See specDifference.png)
[S1,F1,T1,S1] = spectrogram(y1,window, noverlap,2048, Fs, 'yaxis');
[S2,F2,T2,P2] = spectrogram(y2,window, noverlap,2048, Fs, 'yaxis');
surf(T2,F2,abs(abs(S1)-abs(S2)),'edgecolor','none'); axis tight; colormap(hot), view(0,90);
This specDifference.png plot allows differences between spectrograms to be visualized. The objective however is to quantify the difference in order to automate the data collection and analysis.
The rationale for using the spectrogram vs comparing the 2-D FFT or PSD plot and calculating the cross correlation or other metric is because this is a mechanism's open-closing event. Visualizing in 2D potentially hides frequency signatures at specific points in time which may serve as fault indicators. Additionally the goal is to quantitatively differentiate normal condition from varying degrees of degraded condition.

  0 Comments

Sign in to comment.

2 Answers

Answer by Zhao Wang on 10 Jan 2017

I understand that you want to quantify the difference between two spectrograms and use this quantitative information in fault diagnosis. With regards to the objective, the difference should be with respect to a range of frequencies. You may want to calculate the average power at a particular frequency based on the power spectral density (PSD) obtained using the "spectrogram" function. In addition, the spectral moments may also help in the fault diagnosis application.
In order to obtain a relationship between the two signals with respect to frequency, you can compute the cross power spectral density using the "cpsd" function, such as
>> cpsd(y1,y2,window, noverlap,2048, Fs);
For more details about the "cpsd" function, see the following link:

  0 Comments

Sign in to comment.


Answer by Ignas A.
on 19 Nov 2018

Hello James,
after analysing your question I have made few remarks.
First of all there is mistake in your code naming power spectral density as S1 insted of P1:
[S1,F1,T1,S1] = spectrogram(y1,window, noverlap,2048, Fs, 'yaxis'); % You have named PSD as S1 insted of P1 (your style)
[S2,F2,T2,P2] = spectrogram(y2,window, noverlap,2048, Fs, 'yaxis');
Next you should consider ploting results in log scale 10*log10(abs(difference)).
Good luck
Ignas

  0 Comments

Sign in to comment.