matlab中的反正切函数

来源:互联网 发布:mac air散热器 编辑:程序博客网 时间:2024/05/16 07:22

    Matlab 中求相位的函数有 phase atan2  angle  atan

Phase和angle的区别:

1Phase 支持标量和一维向量输入  angle 可以输入任意矩阵,

2相邻相位角差的绝对值大于3.5时,phase会对相位角做修正,angle则不会,例如

a=[-1+i,-1-i];  phase(a)结果为[-2.3562  -3.9270],

  而angle(a)结果为[-2.3562  2.3562].

这两点区别可以从它们的源代码中看出来,在命令行中键入edit phase和edit angle即可以得到

function PHI=phase(G)[nr,nc] = size(G);if min(nr,nc) > 1    error(sprintf(['PHASE applies only to row or column vectors.'...        '\nFor matrices you have to decide along which dimension the'...        '\nphase should be continuous.']))endif nr>nc    G = G.';endPHI=atan2(imag(G),real(G));N=length(PHI);DF=PHI(1:N-1)-PHI(2:N);I=find(abs(DF)>3.5);for i=I    if i~=0,        PHI=PHI+2*pi*sign(DF(i))*[zeros(1,i) ones(1,N-i)];    endendif nr>nc    PHI = PHI.';end

function p = angle(h)p = atan2(imag(h), real(h));

从angle.m中可见,angle实际上是atan2(imag,real)的形式,imag和real都为实数

另外,还有个求反正切的函数atan,它与atan2的区别在于:1.atan(x)得出的结果区间是[-pi/2,pi/2],atan2(x)的区间是[-pi,pi]

2.atan(x)只能用于求实数,atan2(x)可以用于求实数或者复数的相位

在matlab中键入   x=-20:0.01:20; y=plot(x,atan(x));grid on;结果如下:


键入x=-20:0.01:20;y=plot(x,atan2(x));grid on;结果如下:





0 0
原创粉丝点击