Time-Frequency Reassignment using Spectrogram Function

10 vues (au cours des 30 derniers jours)
Alejandro Delgado-Castro
Alejandro Delgado-Castro le 21 Mar 2017
Commenté : Star Strider le 21 Mar 2017
Dear Colleagues. I'm trying to obtain the reassigned version of a spectrogram using Matlab's built-in function spectrogram. Instead of plotting the reassigned version automatically, which works fine, I'm interested in assigning the modified spectrogram to a variable, using the following command:
Reassigned_Spec = spectrogram(In_Sig,Win,F_Size-H_Size,F_Size,fs,'reassign','yaxis');
The problem is that the data that I'm getting into the output variable is not the reassigned spectrogram, it is just the normal spectrogram. Any idea why this is happening? Thanks.
  1 commentaire
Alejandro Delgado-Castro
Alejandro Delgado-Castro le 21 Mar 2017
Well, I have solved the problem myself and wanted to share the solution I found in case someone else is trapped into the same situation. The key thing is that Matlab returns the reassigned spectrogram in the same structure used to return the normal power spectrogram, which is a different structure in the sequence of output variables. So, the command I finally used looks like this:
[~,~,~,Reassigned_Spec] = spectrogram(Ori_Sig,Win,F_Size-H_Size,F_Size,fs,'power','reassigned');
The returned matrix is equivalent to the one automatically plotted when no output variable is specified.

Connectez-vous pour commenter.

Réponse acceptée

Star Strider
Star Strider le 21 Mar 2017
You most likely have to get the data from the figure itself. It took some handle-spelunking to find this (in R2017a, I’m still reading the Release Notes). I never needed to do this, so it was something of an education.
This is from one of the examples in the documentation for the spectrogram function. It seems to provide the information in the plot that spectrogram produces.
The Example Code
Fs = 1000;
t = 0:1/Fs:2;
y = chirp(t,100,1,200,'quadratic');
figure(1)
spectrogram(y,kaiser(128,18),120,128,Fs,'reassigned','yaxis')
Ch = get(gca, 'Children')
Xd = Ch.XData;
Yd = Ch.YData;
Cd = Ch.CData;
figure(2)
surf(Xd, Yd, Cd)
grid on
  2 commentaires
Alejandro Delgado-Castro
Alejandro Delgado-Castro le 21 Mar 2017
Thanks for your answer. I also found a way to extract the reassigned spectrogram directly from the function by rearranging the order of the output variables.
Star Strider
Star Strider le 21 Mar 2017
My pleasure.
I saw your solution in the documentation, but did not test it in my code.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Time-Frequency Analysis dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by