Plotting matrix as spectrogram
13 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Sania Gul
am 26 Aug. 2022
Kommentiert: Robert U
am 26 Aug. 2022
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 Kommentare
Robert U
am 26 Aug. 2022
testData = randn(256,16);
fh = figure;
ah = axes(fh);
surf(ah,testData);
I was not able to reproduce the described error by the given information.
Kind regards,
Robert
Akzeptierte Antwort
Robert U
am 26 Aug. 2022
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');
size(Q)
Kind regards,
Robert
4 Kommentare
Robert U
am 26 Aug. 2022
Have a look here: https://itecnote.com/tecnote/matlab-remove-border-around-matlab-plot/
There is still some manual work required to get the desired result.
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!