Phase angle calculation confusion
16 次查看(过去 30 天)
显示 更早的评论
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?
0 个评论
回答(1 个)
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
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
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 Center 和 File Exchange 中查找有关 Spectral Analysis 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!