Phase angle calculation confusion
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (1)
Sulaymon Eshkabilov
le 4 Nov 2021
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 commentaires
Sulaymon Eshkabilov
le 4 Nov 2021
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
le 4 Nov 2021
Read this article of wiki that gives a full description of "phase" and "phase shift": https://en.wikipedia.org/wiki/Phase_(waves)
Voir également
Catégories
En savoir plus sur Transforms dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!