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

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

% Calculate the corresponding analytic signal F\left(s\right) using the Hilbert transform.

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

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

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

%
% Copyright 2018 The MathWorks, Inc.