plotting spectrogram for 3d matrix
25 次查看(过去 30 天)
显示 更早的评论
Hi
I want to make a spectrogram on a matrix and not on a vector
Is there such a possibility?
% this is work for Vector:
r = randi([-130,-50],1,100);
s = spectrogram(r);
spectrogram(r,'yaxis')
But ,i what plot this:
% this is NOT work for matrix:
r = randi([-130,-50],100,100);
s = spectrogram(r);
spectrogram(r,'yaxis')
Another question
Is the MATLAB function also correct for LOG [dBm]?
Because in the first example I in the fig positive values ,
tnx
2 个评论
MarKf
2022-12-1
spectrogram returns the time-frequency spectrum of one signal timeseries, so would a matrix be considered a single signal (in which case spectrogram(r(:)) would work, but it's unlikely this is case), or is each row (or column) a signal from which you want to extract the spectrograms? In that case use a loop or something like fieldtrip. Or maybe you want a periodogram (no time dim).
Log works, the positive values in the result are to be expected by the conversion solution of a non-perfect signal.
回答(1 个)
Nicolas Douillet
2022-12-4
As Marco said, spectrogram takes a vector as input, not matrix. However depending on how your signals are stored in your data matrix you have, you have four different possibilities :
I.1 Case your signal had actually been reshaped in a matrix :
s = spectrogram(r(:))
I.2 Symetric matrix case; same as previous but you will transpose r matrix before :
r = r';
s = spectrogram(r(:))
II.1 Case your matrix actually contains several signals you want to compute the spectrogram and each signal corresponds to one row of the matrix; if you want the spectrogram of the ith row / signal then just write :
s = spectrogram(r(i,:)) % i is the matrix row index
(In a loop or in a cell array function)
II.2 Case each column of the matrix if a signal :
s = spectrogram(r(:,j)) % j is the matrix column index
(In a loop or in a cell array function)
Hope this help. Good work.
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!