เมธอด numpy.rad2deg() แปลงอาร์เรย์มุมจากเรเดียนเป็นองศา คืนค่าสเกลาร์หากอินพุทเป็นสเกลาร์ พารามิเตอร์ out และ where ทำงานคล้าย ufunc ทั่วไป
ขั้นตอนการใช้งาน
import numpy as np
สร้างอาร์เรย์เรเดียนและแปลงเป็นองศา
arr = np.arange(12.)
res = arr * np.pi / 6
print("Array...\n", arr)
print("\nArray datatype...\n", arr.dtype)
print("\nArray Dimensions...\n", arr.ndim)
print("\nNumber of elements in the Array...\n", arr.size)
print("\nRadian array to degrees...\n", np.rad2deg(res))
โค้ดตัวอย่างสมบูรณ์
import numpy as np
arr = np.arange(12.)
print("Array...\n", arr)
print("\nOur Array type...\n", arr.dtype)
print("\nOur Array Dimensions...\n", arr.ndim)
print("\nNumber of elements...\n", arr.size)
res = arr * np.pi / 6
print("\nRadian array to degrees...\n", np.rad2deg(res))
ผลลัพธ์ที่คาดหวัง
Array... [ 0. 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11.] Our Array type... float64 Our Array Dimensions... 1 Number of elements... 12 Radian array to degrees... [ 0. 30. 60. 90. 120. 150. 180. 210. 240. 270. 300. 330.]