下面是我使用的代码:
import matplotlib.pyplot as plt
from scipy import integrate
import numpy as np
def g(t):
return integrate.quad(t, 0, t)
def f(t):
return t ** 3 - g(t)
t1 = np.arange(-5, 5, 0.1)
plt.figure(1)
plt.subplot(211)
plt.plot(t1, f(t1))
plt.show()
这是我收到的错误信息:
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
不用广播就可以这样做
矢量化版本可以这样做(mentioned here)
两者都会导致
相关问题 更多 >
编程相关推荐