我想用参数化来制作曲线的动画(在这里你可以增量地绘制它):x(t) = sin(3t)和y(y) = sin(4t),其中t0,2pi。
尝试:
%matplotlib notebook
import matplotlib.pyplot as plt
import math
import numpy as np
# set the minimum potential
rm = math.pow(2, 1 / 6)
t = np.linspace(-10, 10, 1000, endpoint = False)
x = []
y = []
for i in len(t): #TypeError 'int' object is not iterable
x_i = np.sin( 3 * t[i] )
y_i = np.sin( 4 * t[i] )
x.append(x_i)
y.append(y_i)
# plot the graph
plt.plot(x,y)
# set the title
plt.title('Plot sin(4t) Vs sin(3t)')
# set the labels of the graph
plt.xlabel('sin(3t)')
plt.ylabel('sin(4t)')
# display the graph
plt.show()但是TypeError 'int‘对象是不可迭代的.我怎么才能修复它?
谢谢
发布于 2019-04-15 17:40:47
您正试图迭代一个整数(i in len(t))
相反,您需要迭代数组:
for i in t:
x_i = np.sin( 3 * i )
y_i = np.sin( 4 * i )
x.append(x_i)
y.append(y_i)

https://stackoverflow.com/questions/55686108
复制相似问题