0
저는 프로그래밍에 익숙하지 않아 내 프로그램에 대한 도움을 주시면 감사하겠습니다. 내가 for 루프를 통해 배열에 읽어 그들에 대한 몇 가지 계산을하고 3D 그래프에 결과를 플롯하기 위해 노력하고있어,하지만 나에게 오류 제공 :배열을 반복하면서 배열에서 계산을 수행하고 결과를 플로팅 하시겠습니까?
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import numpy as np
import math
from itertools import product, combinations
from numpy import *
fig = plt.figure()
ax = fig.gca(projection='3d')
ax.set_aspect("equal")
ra_day = loadtxt("RA Days.txt")
ra_minute = loadtxt("RA Minutes.txt")
ra_second = loadtxt("RA Seconds.txt")
ra = ra_day + (ra_minute/60) + (ra_second/3600)
dec_day = loadtxt("DEC Days.txt")
dec_minute = loadtxt("DEC Minutes.txt")
dec_second = loadtxt("DEC Seconds.txt")
dec = dec_day + (dec_minute/60) + (dec_second/3600)
dist = loadtxt("Distance.txt")
for i in range(len(ra)):
x = math.cos(ra[i]) * (dist[i] * math.cos(dec[i]))
y = math.sin(ra[i]) * (dist[i] * math.cos(dec[i]))
z = dist * math.sin(dec[i])
ax.scatter([0],[0],[0],color="b",s=100)
ax.scatter([x],[y],[z],color="k",s=100)
plt.show()
: 여기
IndexError: index 753 is out of bounds for axis 0 with size 753
하면 코드의
아마도'ra'와'dec'는 같은 길이가 아닙니다. – roippi
그들은 둘 다 길이 754입니다. –
괜찮아요.하지만 이제는 "TypeError : type int '의 객체에 len()이 없습니다. 심지어 ra, dec 및 dist의 길이가 753 –