I have fft of a signal, I want to calculate phase of that signal?

26 visualizaciones (últimos 30 días)
Shrikant
Shrikant el 16 de Oct. de 2015
Comentada: BA Mustafa el 25 de Jun. de 2022
Sin(2*pi*f*t+phi)...i want phi from the fft of the given signal

Respuestas (1)

Star Strider
Star Strider el 16 de Oct. de 2015
Use the angle function. (You might also want the unwrap function.)
  3 comentarios
Star Strider
Star Strider el 16 de Oct. de 2015
Editada: Star Strider el 16 de Oct. de 2015
The phase is by definition going to be the inverse sine of the value of your signal at t=0, or in a fft, the value (in radians or degrees) of the calculated phase compared to a similar signal with no phase. There appears to be no other way to calculate it.
Example:
t = linspace(0, 10*pi, 2500);
f = 5;
phi = pi/5;
s = [sin(2*pi*f*t); sin(2*pi*f*t + phi)]'; % Create Signals: s(:,1) phase - 0, s(:,2) phase = pi/5
Ts = mean(diff(t));
Fs = 1/Ts;
Fn = Fs/2;
fts = fft(s)/length(t); % Do FFT
Fv = linspace(0, 1, fix(length(t)/2)+1)*Fn;
Iv = 1:length(Fv);
[pk,ix] = max(abs(fts(Iv,:)));
phsmin = [min(angle(fts(ix(1),:))); max(angle(fts(ix(2),:)))];
phsminpi = phsmin*pi;
phsdif = diff(phsmin); % Calculate Phase Difference
out = sprintf('Phase difference = %.3f rad', phsdif)
figure(1)
subplot(2,1,1)
semilogy(Fv, abs(fts(Iv,:)))
grid
subplot(2,1,2)
plot(Fv, angle(fts(Iv,:)))
grid
BA Mustafa
BA Mustafa el 25 de Jun. de 2022
t = 1 : 1000;
phaseshift= pi/5 ;
s1 = sin (2*pi*t/500);
s2 = sin (2*pi*t/500+ phaseshift);
Para1=s1;
Para2=s2;
time=t;
h1 = hilbert (Para1);
h2 = hilbert (Para2);
p1 = unwrap(angle(h1));
p2 = unwrap(angle(h2));
figure
plot (t,p1,t,p2);
title('evolution des phases des deux signaux','FontWeight','bold','FontSize',12)
xlabel('t (temps en secondes)','FontWeight','bold','FontSize',12);
ylabel('phase en radian','FontWeight','bold','FontSize',12);
legend('s1','s2');
grid on;
Depha_en_rad = mean (p2-p1)
Depha_en_degre = rad2deg(Depha_en_rad)

Iniciar sesión para comentar.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by