Clear Filters
Clear Filters

How do I plot multiple spectrogram of a wavefile in a subplot?

12 views (last 30 days)
I need to plot multiple spectrograms(using STFT) in a single subplot. The first figure is the plot of wavefile (silence removed). Now the second figure should be the spectrogram using 'jet' and the third figure should be the greyscale spectrogram. But when I write the code below:
subplot(2,1,1);
plot(yEdited);
title('Silence Removal');
grid on;
subplot(2,1,2);
imagesc(t,f,S_log);
colormap('jet');
axis xy;
subplot(2,1,3);
imagesc(t,f,S_log);
axis xy;
colormap(flipud(gray));
axis xy;
The second and the third figure becomes exactly the same. I don't understand why! The second figure should be a coloured one and the third one should be the gray-scale.

Accepted Answer

Adam Danz
Adam Danz on 6 Aug 2018
That's because your command
subplot(2,1,2);
creates a grid of subplots that are [2-by-1]; hence, only 2 subplots. You're not creating 3 subplots. If you want 3 subplots stacked vertically you need to call
subplot(3,1,1);
subplot(3,1,2);
subplot(3,1,3);

More Answers (0)

Categories

Find more on Time-Frequency Analysis in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!