function [A, phase, i_f] = IF_sig(sig, fs)
%IF_sig Calculates instantanous frequency of the signal
%   Input: sig: the signal
%           fs: the sampling frequency
%   Output: Amplitude of the analytic signal
%           Phase of the analytic signal
%           Instantanous frequency of the signal (derivative of phase)
z = sig + 1i*hilbert(sig);
A = abs(z);
phase = (angle(z));
i_f = fs/(2*pi)*diff(unwrap(angle(z)));
i_f = [i_f; 0];
end

