Plotting matrix as spectrogram

조회 수: 14 (최근 30일)
Sania Gul
Sania Gul . 2022년 8월 26일
댓글: Robert U . 2022년 8월 26일
I want to plot a matrix of 256* 16, as spectrogram. But when I use surf command to do so, I got spectrogram of size 343*436. I want the image to be of same size as that of matrix i.e. 256*16. Kindly suggest any solution without cropping or resizing the image as both of them distorts the quality.
  댓글 수: 3
Sania Gul
Sania Gul 2022년 8월 26일
[Q,F,T] = spectrogram(audio,hann(512),256,512,Fs,'yaxis');
colormap parula
shading interp
view([0 90])
axis tight
export_fig AA.jpg -native -c[31 52 46 72]% top right bottom left
% reading the image
>>The value of I=343x436x3 uint8, but the size of matrix Q was only 256x16, and I want 'I' to be also 256x16x3 uint8

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

채택된 답변

Robert U
Robert U 2022년 8월 26일
Hi Sania Gul,
The values you provide are not consistent. I assume your "audio" is a vector of a certain length N, sampled with the frequency Fs.
Applying the function spectrogram with the window-length 512, overlap 256 and NFFT of 512 lead certainly to the dimension of Q of NFFT/2+1 = 257 and ((N - 512)/(512-256)).
If you want Q to be 257 x 16 you would have to provide a snippet of roughly 4600 samples.
fs = 60e3;
t = 0:1/fs:4599/fs;
x1 = vco(sawtooth(2*pi*t,0.5),[0.1 0.4]*fs,fs);
[Q,F,T] = spectrogram(x1,hann(512),256,512,fs,'yaxis');
ans = 1×2
257 16
Kind regards,
  댓글 수: 4
Robert U
Robert U 2022년 8월 26일
There is still some manual work required to get the desired result.

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

추가 답변 (0개)


Help CenterFile Exchange에서 Descriptive Statistics에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by