plotting spectrogram for 3d matrix

조회 수: 33 (최근 30일)
shahar
shahar 2022년 12월 1일
답변: Nicolas Douillet 2022년 12월 4일
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
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.
shahar
shahar 2022년 12월 4일
I thought I would be able to produce a graph similar to spectrum instruments that produce a spectrogram

댓글을 달려면 로그인하십시오.

답변 (1개)

Nicolas Douillet
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.

카테고리

Help CenterFile Exchange에서 Smoothing and Denoising에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by