fft phase plot of pure sine function, why so messy?

1.1k Views Asked by At

I am plotting the phase plot of $sin(2*pi*60*x)$ in the frequency domain. Ideally, we should only see two peaks. How come this is not the case in matlab?

Fs=1/0.001;
x=0:1/Fs:1.8-1/Fs;

close all;

A=sin(60*2*pi.*x);
B=sin(180*2*pi.*(x)+pi/2);
fa=fftshift(fft(A));
fb=fftshift(fft(B));
f=linspace(-0.5, 0.5, length(x))*Fs;
figure;
subplot(2,1,1);
plot(f,abs(fa));
subplot(2,1,2);
plot(f,abs(fb));

figure;
subplot(2,1,1);
plot(f,radtodeg(angle(fa))); xlim([57,62]);
subplot(2,1,2);
plot(f,radtodeg(angle(fb))); xlim([177 185]);

enter image description here

enter image description here

1

There are 1 best solutions below

10
On BEST ANSWER

You're seeing two peaks in the magnitude plot, just as you should.

The reason you're not seeing two peaks in the angle plot is that the complex-argument function is ill-conditioned near zero. That is, a number that is "close to zero" doesn't necessarily have an angle that's close to zero.

So, even though fa and fb are good approximations of the corresponding transform, their arguments might differ from what they should be wherever their magnitude should hit zero.