%% Logarithmic Chirp
% Generate a logarithmic chirp sampled at 1 kHz for 10 seconds. The instantaneous frequency is 10 Hz initially and 400 Hz at the end.

t = 0:1/1e3:10;
fo = 10;
f1 = 400;
y = chirp(t,fo,10,f1,'logarithmic');

%
% Compute and plot the spectrogram of the chirp. Divide the signal into segments such that the time resolution is 0.2 second. Specify 99% of overlap between adjoining segments and a spectral leakage of 0.85.

pspectrum(y,t,'spectrogram','TimeResolution',0.2, ...
    'OverlapPercent',99,'Leakage',0.85)

%
% Use a logarithmic scale for the frequency axis. The spectrogram becomes a line, with high uncertainty at low frequencies.

ax = gca;
ax.YScale = 'log';

% Copyright 2015 The MathWorks, Inc.