MATLAB: Extracting phase information of a signal buried in noise using FFT

fft

I am trying to extract the phase information of a noisy signal using fft, but unable to understand the plot obtained using 'angle' command.
fs=5000;
dt=1/fs;
StopTime =0.25; % seconds

t = (0:dt:StopTime-dt)'; % seconds
Fc = 60; % hertz
ph=30*pi/180;
x = 4*sin(2*pi*Fc*t+ph);
for i=1:length(t)
xn(i)=x(i)+randn;
end
X=fft(xn);
xx=(angle(fftshift(X)));
plot(xx)
I am unable to understand this plot. How can I get a phase spectrum showing peak with only 'ph' value?

Best Answer

See the many examples in the net to interprete the output of FFT, e.g. http://www.gaussianwaves.com/2015/11/interpreting-fft-results-obtaining-magnitude-and-phase-information/:
fs = 5000;
dt = 1/fs;
StopTime = 0.25; % seconds

t = (0:dt:StopTime-dt)'; % seconds
Fc = 60; % hertz
ph = 30*pi/180;
xn = 4*sin(2*pi*Fc*t+ph) + randn(size(t));
N = length(t);
X = 1/N * fftshift(fft(xn));
df = fs/N; % frequency resolution
f = (-N/2:N/2-1) *df; % ordered frequencies
P = atan2(imag(X), real(X)) * 180/pi; % Too noisy to see the peaks
figure;
plot(f, P);
Y = X;
Y(abs(Y) < 0.1) = 0; % Reduce noise
P2 = atan2(imag(Y), real(Y)) * 180/pi;
figure;
plot(f, P2)
Related Question