%% Instantaneous Frequency of Nonstationary Signal
% Generate a signal sampled at 5 kHz for 4 seconds. The signal consists of a set of pulses of decreasing duration separated by regions of oscillating amplitude and fluctuating frequency with an increasing trend. Plot the signal.

fs = 5000;
t = 0:1/fs:4-1/fs;

s = besselj(0,1000*(sin(2*pi*t.^2/8).^4));

plot(t,s)

%
% Estimate the time-dependent frequency of the signal as the first moment of the power spectrogram. Plot the power spectrogram and overlay the instantaneous frequency.

instfreq(s,fs)

% Copyright 2012 The MathWorks, Inc.