- #1

gulaman

- 18

- 0

i can't display the graph and i have been having this error:

Traceback (most recent call last):

File "C:\Documents and Settings\AP155user38\Desktop\gladys python codes\differential equations and runge-kutta\1ODE.py", line 20, in <module>

Y[i+1] = rk4(t

*, Y*

*, f)*

File "c:\python25\lib\site-packages\matplotlib-0.98.3.0001-py2.5-win32.egg\matplotlib\mlab.py", line 928, in rk4

yout = np.zeros( (len(t),), np.float_)

TypeError: object of type 'function' has no len()

i need help in understanding this so i could move on with solving the error. :)

i hope you guys could help me out.

here's my code:

from scipy import *

from pylab import *

h = 0.1 #time step

ti = 0. #start

tf = 10. #end

t = arange(ti, tf, h) #time array

N = len(t) #number of time steps

Y = zeros(N) #stores value of y at each time step

Y[0] = 0. #initial condition

def f(t, Y):

dYdt = -9.81 - 0.5*Y

return dYdt

for i in range(N-1):

Y[i+1] = rk4(tFile "c:\python25\lib\site-packages\matplotlib-0.98.3.0001-py2.5-win32.egg\matplotlib\mlab.py", line 928, in rk4

yout = np.zeros( (len(t),), np.float_)

TypeError: object of type 'function' has no len()

i need help in understanding this so i could move on with solving the error. :)

i hope you guys could help me out.

here's my code:

from scipy import *

from pylab import *

h = 0.1 #time step

ti = 0. #start

tf = 10. #end

t = arange(ti, tf, h) #time array

N = len(t) #number of time steps

Y = zeros(N) #stores value of y at each time step

Y[0] = 0. #initial condition

def f(t, Y):

dYdt = -9.81 - 0.5*Y

return dYdt

for i in range(N-1):

Y[i+1] = rk4(t

*, Y**, f)*

plot(t,Y)

show()

thanx.

gulaman

Quezon City, Philippinesplot(t,Y)

show()

thanx.

gulaman

Quezon City, Philippines