Question

I have a wav file, and I wanted to get frequency-time array of the file . for getting, I tried STFT in matlab.

[s f t]= spectrogram(x,window,overlap,N,FS);
figure(1)
imagesc(t,f,log10(abs(s)));

[X,Y]=meshgrid(t,f);
Z=log10(abs(s));
mesh(X,Y,Z);

I got a image that I wanted. But I don't know what do {s,f t,X,Y and Z} mean. What do I need for getting frequency-time array.

Was it helpful?

Solution

From the MATLAB documentation:

[S,F,T] = spectrogram(...) returns a vector of frequencies, F, and a vector of times, T, at which the spectrogram is computed.

S, F and T are exactly what you need. The T variable contains the times at which the wav file contains frequencies F with the corresponding STFT in variable S. On a logarithmic scale (for arguably better visibility of frequency content), you calculate Z=log10(abs(s));.

X and Y are used to create the mesh plot, but if you want to know: they contain T and F in matrix form with T on each row of X and F on each column of Y.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top