📜  Python中的 numpy.angle()

📅  最后修改于: 2022-05-13 01:55:18.099000             🧑  作者: Mango

Python中的 numpy.angle()

当我们想要计算复杂参数的角度时,使用numpy.angle()函数。复数由“x + yi”表示,其中 x 和 y 是实数并且i= (-1)^1/2 。角度由公式tan-1(x/y).

代码#1:工作

# Python program explaining
# numpy.angle() function
# when we want answer in radian
  
import numpy as geek
in_list =[2.0, 1.0j, 1 + 1j]
  
print ("Input  list : ", in_list)
    
out_angle = geek.angle(in_list) 
print ("output angle in radians : ", out_angle) 

输出 :

Input  list :  [2.0, 1j, (1+1j)]
output angle in radians :  [ 0.          1.57079633  0.78539816]


代码 #2:工作

# Python program explaining
# numpy.angle() function
# when we want answer in degrees
  
import numpy as geek
in_list =[2.0, 1.0j, 1 + 1j]
  
print ("Input  list : ", in_list)
    
out_angle = geek.angle(in_list, deg = True) 
print ("output angle in degrees : ", out_angle) 

输出 :

Input  list :  [2.0, 1j, (1+1j)]
output angle in degrees :  [  0.  90.  45.]