ในการคืนค่ามุมของอาร์กิวเมนต์ที่ซับซ้อน ให้ใช้วิธี numpy.angle() ใน Python วิธีการคืนค่ามุมทวนเข็มนาฬิกาจากแกนจริงบวกบนระนาบเชิงซ้อนในช่วง (-pi,pi] โดยมี dtype เป็น numpy.float64 พารามิเตอร์ที่ 1 z, A จำนวนเชิงซ้อนหรือลำดับของจำนวนเชิงซ้อน พารามิเตอร์ที่ 2, 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)
ในการคืนค่ามุมของอาร์กิวเมนต์ที่ซับซ้อน ให้ใช้วิธี numpy.angle() ใน Python Numpy วิธีการคืนค่ามุมทวนเข็มนาฬิกาจากแกนจริงบวกบนระนาบเชิงซ้อนในช่วง (-pi, pi] โดย dtype เป็น numpy.float64 −
print("\nResult...\n", np.angle(arr)) ตัวอย่าง
import numpy as np
# Create an array using the array() methodd
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...\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... [0. 1.57079633 0.78539816]