%% Fourier Synchrosqueezed Transform of Chirps
% Compute and display the Fourier synchrosqueezed transform of a quadratic chirp that starts at 100 Hz and crosses 200 Hz at t = 1 s. Specify a sample rate of 1 kHz. Express the sample time as a duration scalar.

fs = 1000;
t = 0:1/fs:2;
ts = duration(0,0,1/fs);

x = chirp(t,100,1,200,'quadratic');

fsst(x,ts,'yaxis')

title('Quadratic Chirp')

%
% The synchrosqueezing algorithm works under the assumption that the frequency of the signal varies slowly. Thus the spectrum is better concentrated at early times, where the rate of change of frequency is smaller.
% Compute and display the Fourier synchrosqueezed transform of a linear chirp that starts at DC and crosses 150 Hz at t = 1 s. Use a 256-sample Hamming window.

x = chirp(t,0,1,150);

fsst(x,ts,hamming(256),'yaxis')

title('Linear Chirp')

%
% Compute and display the Fourier synchrosqueezed transform of a logarithmic chirp. The chirp is sampled at 1 kHz, starts at 20 Hz, and crosses 60 Hz at t = 1 s. Use a 256-sample Kaiser window with β = 20.

x = chirp(t,20,1,60,'logarithmic');

[s,f,t] = fsst(x,fs,kaiser(256,20));

clf
mesh(t,f,(abs(s)))

title('Logarithmic Chirp') 
xlabel('Time (s)')
ylabel('Frequency (Hz)')
view(2)

%
% Use a logarithmic scale for the frequency axis. The transform becomes a straight line.

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

% Copyright 2012 The MathWorks, Inc.