%% Complex Chirp
% Generate a complex linear chirp sampled at 1 kHz for 10 seconds. The instantaneous frequency is –200 Hz initially and 300 Hz at the end. The initial phase is zero.

t = 0:1/1e3:10;
fo = -200;
f1 = 300;

y = chirp(t,fo,t(end),f1,'linear',0,'complex');

%
% 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)

%
% Verify that a complex chirp has real and imaginary parts that are equal but with {90}^{\circ } phase difference.

x = chirp(t,fo,t(end),f1,'linear',0) + 1j*chirp(t,fo,t(end),f1,'linear',-90);

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

% Copyright 2020 The MathWorks, Inc.