instantaneous frequency for a complex signal

Let $$s(t)$$ be a complex signal. I would like to know how to find a signal from its instantaneous frequency. I programmed the following function which calculates the instantaneous frequency.

function [f]=instfreq(s)

z=unwrap(angle(s));
f=diff(z)/(2*pi);

end


Example on a chirp:

clear all;close all;clc;

B=20e3;
fs=100e3;
T=10e-3;

%% LFM
t=(0:T*fs-1)*(1/fs);
lfm=exp(1i*2*pi*(-(B/2)*t+(B/(2*T))*t.^2));

%% Instantaneous frequency
[f]=instfreq(lfm);
f=[f f(end)]; %adding an element to have the same length as t

%% Signal reconstruction
phi=cumtrapz(t,f);
sig=exp(1i*2*pi*phi);

plot(abs(fftshift(fft(sig))))


We cannot find the starting chirp ($$sig \neq lfm$$). For example, the spectrum of the reconstructed signal is not the same. Its bandwidth is not $$20$$ kHz.

• So remove the call to hilbert and just pass s in as y. hilbert changes a real-valued signal to a complex-valued signal. The signal lfm is already complex-valued.
– Peter K.
Commented Mar 25 at 20:59
• I agree with you. However, I still have a problem. Once I have found the instantaneous frequency, I can do the opposite operation to find the chirp. However, this is not the case here, I cannot find the starting chirp. I use the cumtrapz(t,f) command for integration and normally I have to find the chirp phase.
– bubu
Commented Mar 26 at 10:17

This line

[f]=instfreq(lfm);


should be

[f]=instfreq(lfm)*fs;


If I do that and plot the true $$\phi$$ and the estimated $$\phi$$ then they overlap:

Code Below

clear all;
clc;

B=20e3;
fs=100e3;
T=10e-3;

%% LFM
t=(0:T*fs-1)*(1/fs);
true_phi = 2*pi*(-(B/2)*t+(B/(2*T))*t.^2);
lfm=exp(1i*true_phi);

%% Instantaneous frequency
[f]=instfreq(lfm)*fs;
f=[f f(end)]; %adding an element to have the same length as t

%% Signal reconstruction
est_phi=cumtrapz(t,f);
sig=exp(1i*est_phi);

plot(true_phi,'.');
hold on;
plot(est_phi,'r');
hold off;


• Thank you for your help, my problem is solved.
– bubu
Commented Mar 27 at 18:00
• @bubu The usual way to say that is to either give an upvote or give the green check mark or both! :-)
– Peter K.
Commented Mar 27 at 22:19