%% Calculate Instantaneous Frequency
% Create a real-valued signal f(s) with two frequency components, 60 Hz and 90 Hz.

syms s f(x) F(t)
f(s) = sin(2*pi*60*s) + sin(2*pi*90*s)

% Calculate the corresponding analytic signal F(t) using the inverse Hilbert transform.

F(t) = ihtrans(f(s),t) + 1i*f(t)

% Calculate the instantaneous frequency of F(t) using
% f_{\rm instant}(t)=\frac{1}{2\pi} \frac{d\phi(t)}{dt},
% where \phi\left(t\right)=\arg\left[ F(t)\right] is the instantaneous phase of the analytic signal.

InstantFreq(t) = diff(angle(F(t)),t)/(2*pi);
assume(t,'real')
simplify(InstantFreq(t))

%
% Copyright 2018 The MathWorks, Inc.