Computing frequency from phase angle. How to remove the frequency spikes?

10 views (last 30 days)
I want to calculate frequency of a complex signal from its angle deviation. The problem with this is that I am getting large values of difference. See images attached.
How can I remove the large spikes, what method I can use to smooth the data at those samples. Note: The signal or angle deviation can actually be random or varying with time.
ps - the x-axis labeled as time in seconds, which is actually number of time steps or samples.

Accepted Answer

David Goodmanson
David Goodmanson on 23 May 2018
Hi Jan,
The angle function is restricted to -pi < angle < pi, so in your first plot the angle has a series of sudden jumps from +pi down to -pi, which is phase wrap. You can use the unwrap function to make a continuous function, and then differentiate that. It looks like your frequency is around .04, so:
f0 = .04
t = 0:.01:120;
y = exp(2*pi*i*f0*t);
a = angle(y);
a1 = unwrap(a);
figure(1)
plot(t,a1)
ylabel('angle')
f = (diff(a1)./diff(t))/(2*pi);
f1 = min(f)
f2 = max(f)
There is no point in plotting f since for this waveform it equals .04 for all t. Absent the jumps, your f appears to be up around 50, so it appears that something is not quite right there.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!