plotting spectrogram for 3d matrix

15 views (last 30 days)
shahar on 1 Dec 2022
Answered: Nicolas Douillet on 4 Dec 2022
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);
But ,i what plot this:
% this is NOT work for matrix:
r = randi([-130,-50],100,100);
s = spectrogram(r);
Another question
Is the MATLAB function also correct for LOG [dBm]?
Because in the first example I in the fig positive values ,
shahar on 4 Dec 2022
I thought I would be able to produce a graph similar to spectrum instruments that produce a spectrogram

Sign in to comment.

Answers (1)

Nicolas Douillet
Nicolas Douillet on 4 Dec 2022
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.


Find more on Time-Frequency Analysis in Help Center and File Exchange




Community Treasure Hunt

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

Start Hunting!