필터 지우기
필터 지우기

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

조회 수: 44 (최근 30일)
Shrikant
Shrikant 2015년 10월 16일
댓글: BA Mustafa 2022년 6월 25일
Sin(2*pi*f*t+phi)...i want phi from the fft of the given signal

답변 (1개)

Star Strider
Star Strider 2015년 10월 16일
Use the angle function. (You might also want the unwrap function.)
  댓글 수: 3
Star Strider
Star Strider 2015년 10월 16일
편집: Star Strider 2015년 10월 16일
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 2022년 6월 25일
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)

댓글을 달려면 로그인하십시오.

태그

Community Treasure Hunt

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

Start Hunting!

Translated by