【发布时间】:2016-11-03 10:51:00
【问题描述】:
我必须为动画准备数据,但遇到了问题
t = numpy.linspace(0, 1/10, 1/10000)
x = [1, 3, 5, 7, 9]
S = [ 0.09642699 -1.75110819 -0.00915477 -0.42833324 -0.01772692 -0.00885592
-0.01136874 0.4106214 0.09199903 1.73339635]
realResponse = [x * numpy.cos(311.64*t) for x in numpy.dot(eigenvector, modalconstant)]
#realResponse = numpy.delete(realResponse, my_list, axis=0)
现在这个realResponse 列表结果是......好吧......什么都没有
print(realResponse)# prints: [array([], dtype=float64),
array([], dtype=float64), array([], dtype=float64),....
我不知道似乎是什么问题。我仔细关注this topic.
反正我也试过了
realResponse = list()
for i in range(0, 10):
realResponse[i] = S[i] * numpy.cos(eigenvalue[311.64*t)
结果是一个错误:
IndexError: 列表赋值索引超出范围
【问题讨论】:
-
错误是什么?而且,
t不是一个值! -
@Aidin: IndexError: list assignment index out of range
-
是的。
t应该是一个变量(时间)。我仍然需要弄清楚如何正确准备我的数据,这是我第一次在 python 中做动画。 -
我不是很了解python,但是你不需要像在循环中那样为每个
t值做这个,而不是仅仅插入t吗?我的意思是,现在你有两个变量,x和t -
您希望
realResponse成为矩阵吗?