Time-Frequency Reassignment using Spectrogram Function

6 次查看(过去 30 天)
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 个评论
Alejandro Delgado-Castro
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.

请先登录,再进行评论。

采纳的回答

Star Strider
Star Strider 2017-3-21
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 个评论
Alejandro Delgado-Castro
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 2017-3-21
My pleasure.
I saw your solution in the documentation, but did not test it in my code.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Time-Frequency Analysis 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by