How to determine the lag angle between two snine wave

6 次查看(过去 30 天)
% I need to calculate the angle of the rotational vector B=Bmx+i*Bmy
% wheree Bmx and Bmy are 90 degree outof phase
% here is the code
clc
clear
close all
f=50;w=2*pi*f;Tperiod=1/f;Tmax=4*Tperiod;Dt=Tperiod/(6*f);N=(Tmax/Dt)+1;
t0=0.00001;
t=zeros(N,1); Bmx=zeros(N,1); Bmy=zeros(N,1);
thetaB=90;Bmax=1.6;
for k=1:N+1
t(k)=t0+Dt*(k-1);
Bmx(k)=Bmax*sin(w*t(k));
Bmy(k)=Bmax*sin(w*t(k)-(thetaB)*pi/180);
end
%when I use this command the lag angle between Bmx ,,and Bmy is not 90
phase_difB= acos( dot(Bmx,Bmy) / (norm(Bmx)*norm(Bmy)) )*180/pi;
% the result is 94 and the lag angle between is is thetaB=90;
% and if there is another vector H=Hx+i*Hy
%how can I determine the angle between B and H
%Regards

回答(2 个)

the cyclist
the cyclist 2022-1-14
I believe you will only get exactly 90 if you could sample at infinitesimal resolution and/or a signal that extends for infinite time.
Due to the finite resolution and extent, you will only get an approximation.

David Goodmanson
David Goodmanson 2022-1-14
编辑:David Goodmanson 2022-1-14
Hi Hassan
Consider the complex wave
exp(i*(w*t+theta)) = cos(w*t+theta) + i*sin(w*t+theta)
While it's true that the cos and sin terms are 90 degrees out of phase, I think there are better ways to look at things than concentrating on that particular phase shift. It's better to take that phase shift for granted an look at the complex wave as a single entity:
exp(i*(w*t+theta)) = exp(i*w*t)*exp(i*theta)
In a system with several components oscillating at a single frequency, the exp(i*w*t) factor is common to all of them and the exp(i*theta) factor (the phasor) determines the relative phase of the components. For example,
t = (0:.001:1)'; % column vector
f = 10
w = 2*pi*f;
A1 = 5;
A2 = 2;
th1 = 30*(pi/180);
th2 = 175*(pi/180);
sig1 = A1*exp(i*(w*t +th1));
sig2 = A2*exp(i*(w*t +th2)); % the two systems have relative phase of 145 degrees.
% determine the relative angle by similar method to that in the question
relative_angle = angled((sig1'*sig2)/sqrt((sig1'*sig1)*(sig2'*sig2)))
relative_angle = 145.0000
Here angled was used since it converts to degrees

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by