Phase angle calculation confusion

조회 수: 5 (최근 30일)
Big heads
Big heads 2021년 11월 4일
댓글: Sulaymon Eshkabilov 2021년 11월 4일
I've written a very simple code to calculate phase angle.
I create a sine wave signal and calculate the phase angle of that signal.
Following this MATLAB link,
it is pretty straight forward, so thats what i followed.
freq1=4000;
fs=16000; % sampling frequency
ts=1/fs;
pa=360*ts*freq1*pi/180; % calculate phase angle based on link mentioned below
t=1;
samples=0:1/fs:t;
sinesig=sin(2*pi*freq1*samples); % create a sine wave
yf=fft(sinesig,128);
zf = fftshift(yf);
ly = length(yf);
ft = (-ly/2:ly/2-1)/ly*fs;
% plot(zf)
figure(1)
stem(ft,abs(zf))
xlabel 'Frequency (Hz)'
ylabel '|y|'
grid
tol = 1;
zf(abs(zf) < tol) = 0;
theta = angle(zf);
figure(2)
stem(ft,theta)
xlabel 'Frequency (Hz)'
ylabel 'Phase / \pi'
grid
i got an output. If you look at the resulting curve
and if i also do a max(theta), i get 1.5708 . Everything checks out.
But i read another article,
Going by this article,
ts = 1/fs;
Therefore 360*ts*freq*pi/180
( pi/180 = degrees to radians)
hence if you notice in the code, i have the variable 'pa'. Incidentally this also checks out to 1.5708.
So the assumption is that as the Freq changes, the phase angle will change.
but going back to the earlier code, when i changed the frequency of the sine wave, freq1 = 1000, max(theta) remains 1.5708. and the phase angle figure remains the same as well, whearas 'pa' changes to 0.3927.
I'm confused now. Have i misunderstood something? Why does the theta value remain the same irrespective of diferent frequencies?

답변 (1개)

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2021년 11월 4일
Note that the phase shift and phase angle are NOT the same thing. Above, you are computing the phase shift (pa) that is not a Phase angle.
  댓글 수: 3
Sulaymon Eshkabilov
Sulaymon Eshkabilov 2021년 11월 4일
It is a phase shift NOT a phase. It calls a phase constant (maybe this term is accepted by some communities) as an alternative term for the phase shift, but it is not a phase.
Sulaymon Eshkabilov
Sulaymon Eshkabilov 2021년 11월 4일
Read this article of wiki that gives a full description of "phase" and "phase shift": https://en.wikipedia.org/wiki/Phase_(waves)

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

카테고리

Help CenterFile Exchange에서 Transforms에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by