I'm trying to write a code which allows me to determine the phase of a sine wave from its vector.
given: the sinusoidal signal vector, its frequency
unknown: its phase
I have tried with this code but i don't understand why do i end up getting wrong/ unprecise results
fx=1; phix= 180;
binwidth = 1 / (b-a);
f_index = fx / binwidth +1;
y = abs(fft(x)) / (N/2);
phase = angle(fft(x))* 180/pi+90;
for example here i get 187.2000 instead of 180
I'd be very grateful for your help and clarifications!