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
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值