Get a plot like spectrogram in MATLAB

647 views Asked by At

I would like to get a plot of the same type of the one that I get with spectrogram function, I am trying with contour but I do not get the same result. I have written a small function which compares the two plot. The function records audio for one second and then plot the spectrogram.

function graph_comparison
    a = audiorecorder(44100,16,1);
    recordblocking(a,1);
    y = getaudiodata(a);
    figure
    subplot(1,2,1);
    spectrogram(y);
    s = spectrogram(y);
    subplot(1,2,2);
    contour(mag2db(abs(s))); %mag2db converts intensity in db
    %rotate the second plot
    view(-90, 90); 
    set(gca, 'ydir', 'reverse');
end

Example of plot result: enter image description here

1

There are 1 answers

4
Nisba On

I found it, it is sufficient to replace contour with imagesc.