Time-Frequency Reassignment using Spectrogram Function

조회 수: 7 (최근 30일)
Alejandro Delgado-Castro
Alejandro Delgado-Castro 2017년 3월 21일
댓글: Star Strider 2017년 3월 21일
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
Alejandro Delgado-Castro 2017년 3월 21일
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
Alejandro Delgado-Castro 2017년 3월 21일
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