【发布时间】:2019-01-28 21:24:59
【问题描述】:
我可以使用 atan() 或 atan2() 函数在 Matlab 中提取复数的相位。
atan() 的返回区间限制为[-pi/2,pi/2],atan2() 的返回区间限制为[-pi,pi]。
我想看看我是否可以在每种情况下使用unwrap() 函数解开提取的相位,但unwrap 仅对通过atan2() 提取的相位有效。
R = 1; % Magnitude
theta = linspace(0,6*pi,100); % (radians) Angle array
theta_atan = zeros(1,length(theta)); % Prellocate for calculation
theta_atan2 = zeros(1,length(theta)); % Prellocate for calculation
X = zeros(1,length(theta)); %Prelloc.
Y = zeros(1,length(theta)); %Prelloc.
for i = 1:length(theta)
X(i) = R*cos(theta(i)); % Real part
Y(i) = R*sin(theta(i)); % Imaginary part
theta_atan(i) = atan(Y(i)/X(i));
theta_atan2(i) = atan2(Y(i),X(i));
end
我使用每种方法绘制展开的提取相位:
figure(666)
plot(theta,unwrap(theta_atan));
hold on
plot(theta,unwrap(theta_atan2));
legend('theta atan','theta atan2')
xlabel('input phase')
ylabel('extracted phase')
但是,如您所见,展开仅在 atan2() 情况下有效。
即使我使用unwrap(theta_atan, pi/2)(在这种情况下,展开是基于 pi/2 而不是默认值 pi 的增量),我也无法正确展开 atan() 阶段。
【问题讨论】: