matlab 求虚数的反正切,matlab中的反正切函数 | 学步园

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.']))

end

if nr>nc

G = G.';

end

PHI=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)];

end

end

if 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;结果如下:

2046175.html

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

2046175.html

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值