%% Frequency Along x-Axis
% Generate a quadratic chirp, x, sampled at 1 kHz for 2 seconds. The frequency of the chirp is 100 Hz initially and crosses 200 Hz at t = 1 s.

t = 0:0.001:2;
x = chirp(t,100,1,200,'quadratic');

%
% Compute and display the spectrogram of x.
% Divide the signal into sections of length 128, windowed with a Hamming window.
% Specify 120 samples of overlap between adjoining sections.
% Evaluate the spectrum at \lfloor128/2+1\rfloor=65 frequencies and \lfloor({\tt length(x)}-120)/(128-120)\rfloor=235 time bins.

spectrogram(x,128,120,128,1e3)

%
% Replace the Hamming window with a Blackman window. Decrease the overlap to 60 samples. Plot the time axis so that its values increase from top to bottom.

spectrogram(x,blackman(128),60,128,1e3)
ax = gca;
ax.YDir = 'reverse';

% Copyright 2015 The MathWorks, Inc.