복잡한 인수의 각도를 반환하려면 Python에서 numpy.angle() 메서드를 사용합니다. 이 메서드는 범위(-pi,pi]의 복소수 평면에 있는 양의 실수 축에서 반시계 방향 각도를 반환합니다. dtype은 numpy.float64입니다. 첫 번째 매개변수 z, 복소수 또는 복소수의 시퀀스 두 번째 매개변수 deg, True이면 각도를 반환하고 False이면 라디안(기본값)을 반환합니다.
단계
먼저 필요한 라이브러리를 가져옵니다 -
import numpy as np
array() 메서드를 사용하여 배열 생성 -
arr = np.array([1.0, 1.0j, 1+1j])
배열 표시 -
print("Array...\n", arr) 배열의 유형 가져오기 -
print("\nOur Array type...\n", arr.dtype)
배열의 차원 가져오기 -
print("\nOur Array Dimension...\n",arr.ndim) 배열의 모양 가져오기 -
print("\nOur Array Shape...\n",arr.shape)
복잡한 인수의 각도를 반환하려면 Python Numpy에서 numpy.angle() 메서드를 사용합니다. 이 메서드는 (-pi, pi] 범위의 복소 평면에서 양의 실수 축에서 반시계 방향 각도를 반환하고 dtype은 numpy.float64 -
print("\nResult (radians)...\n", np.angle(arr)) 예시
import numpy as np
# Create an array using the array() method
arr = np.array([1.0, 1.0j, 1+1j])
# Display the array
print("Array...\n", arr)
# Get the type of the array
print("\nOur Array type...\n", arr.dtype)
# Get the dimensions of the Array
print("\nOur Array Dimension...\n",arr.ndim)
# Get the shape of the Array
print("\nOur Array Shape...\n",arr.shape)
# To return the angle of the complex argument, use the numpy.angle() method in Python Numpy
# The method returns the counterclockwise angle from the positive real axis on the complex plane in the range (-pi, pi], with dtype as numpy.float64.
print("\nResult (radians)...\n", np.angle(arr)) 출력
Array... [1.+0.j 0.+1.j 1.+1.j] Our Array type... complex128 Our Array Dimension... 1 Our Array Shape... (3,) Result (radians)... [0. 1.57079633 0.78539816]