Finding phase angle via FFT I am using the FFT to calculate the amplitude and phase of AC cos signal. Regarding amplitude it gives me an accurate result but I get wrong result for a phase: 6 degrees instead of 36 degrees.

My MATLAB code is as follows:

fs=3840;                 % sampling frequency
N=64;                    % number of sample
f=60;                    % signal frequency in hz
w=2*pi*f;
amp=220;                 % ampitude of signal   
delt=[1:N]*2*pi/N;       % sampling time interval
noise=randn(size(delt)); % added noise

sig=zeros(size(delt));
for i=1:1:length(delt)
    sig(i)=noise(i)+amp*cos(w*delt(i)+pi/5);
end

FF=fft(sig,N);
stem(abs(FF))
grid on

REAL=real(FF);
SUM_REAL=sum(REAL)
IMAG=abs(imag(FF));
SUM_IMAG=sum(IMAG)

% *******************************PHASOR REPRESENTATION*******************

real_amp=sqrt(SUM_REAL)                  % Amplitude of real part
imag_amp=sqrt(SUM_IMAG)                  % Amplitude of imaginary part
sumation=real_amp+imag_amp;
amplitude_nominal=sqrt(sumation)/N
phase=atan(abs(imag(FF))/abs(real(FF))) % phase in radians
PHI=abs(phase)*180/pi                   % phase angle in degrees
Since the length of your FFT is exactly one period of your sinusoidal input signal (N = Fs/F0) , the signal will appear in bin 1 (the one above DC) of the FFT result (the conjugate mirror is redundant for strictly real input).  To estimate the phase of the sinusoid of frequency F0, referenced to the start of the data window, just compute the atan2() of the signed imaginary and real components from that single complex bin 1.  No need to abs() components or sum or window or estimate the amplitude or examine any other bin.  Unless you want to sanity check the magnitude of bin 1 to make sure it isn't zero or just numerical noise.