IndexError: index 1 is out of bounds for axis 0 with size 1/ForwardEuler
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am numerically solving for x(t) for a system of first order differential equations. The system is: dy/dt=(C)\*[(-K\*x)+M*A] I have implemented the Forward Euler method to solve this problem as follows: Here is my code: import matplotlib import numpy as np from numpy import * from numpy import linspace from matplotlib import pyplot as plt C=3 K=5 M=2 A=5 #------------------------------------------------------------------------------ def euler (f,x0,t): n=len (t) x=np.array ([x0*n]) for i in xrange (n-1): x[i+1] = x[i] + ( t[i+1] - t[i] ) *