My Spectrogram doesn't look right, and has negative values
Show older comments
Hi,
I am attempting to create a MATLAB App that displays a spectrogram for a chunk of audio. I have it displaying a spectrogram but I want it to look slightly different. The Spectrogram created by my application has negative values and is upside down for some reason. I have included an image of what my Spectrogram looks like and also a photo of what I want it to look like. I don't care so much about the colour scheme, I'm just unsure how to go about removing the negative values, flipping the Spectrogram so increased frequency is going up on the Y-axis, and how to get a non-linear scale for the Y-axis.
This is what my spectrogram looks like for a given piece of audio:

And this is what I would like it to look like using the same piece of audio:

Here is my code, where chunk is just a chunk of a larger piece of audio:
(The negative values in both yticks and yticklabels is just to illustrate that the negative values are there and displayed above positive ones)
[S, F, T] = stft(chunk, app.Fs,Window=kaiser(256,5),OverlapLength=220,FFTLength=512);
imagesc(app.Spectogram, T, F, rot90(log(abs(S'))));
axis(app.Spectogram, 'tight');
yticks(app.Spectogram, [-5000, 50, 100, 500, 1000, 2000, 5000, 10000]);
yticklabels(app.Spectogram, {'-5000Hz' ,'50Hz', '100Hz', '500Hz', '1000Hz', '2000Hz', '5000Hz', '10000Hz'});
set(gca,'YDir','normal');
set(gca, 'YScale', 'log');
Accepted Answer
More Answers (0)
Categories
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!