Thanks for helping :)
I just found a simple scipy/python odeint I could translate, here it is, I 
uncommented ys=array(ys),flatten(), because i don't know what that means, 
but the example works even without it
Now I will try my other programm with your suggestion and I will see the 
result ?
Regards
HG
using PyPlot,PyCall
plt=PyPlot
@pyimport scipy.integrate as integrate
function dₜ(y,x)
    return x-y
end;
xs =linspace(0,5,100)
y0 = 1.0
ys = integrate.odeint(dₜ, y0, xs);
#ys = array(ys).flatten();
plt.plot(xs,ys)
ax = plt.gca() # get current axes
ax[:set_xlim]((0,5));
ax[:set_ylim]((0.6,4.5));


Le lundi 20 juin 2016 17:32:07 UTC+2, Henri Girard a écrit :
>
> I am trying to convert from python to julia, but I don't know how to use 
> y1=integrate.odeint(f,t), apparently I should have add a derivativ ?
>
> --python----------------------
> from scipy.integrate import odeint
> def f(y,t):
>     if t<25:
>         return [y[1],-8*y[0]+0.1*y[1]]
>     elif 25<t<45:
>         return [y[1],-8*y[0]]
>     else:
>         return [y[1],-8*y[0]-0.1*y[1]]
> t=np.linspace(0,35,1000)
> # start from  y=0.01, y’=0
> y1=odeint(f,[0.01,0],t)
> plt.plot(t,y1[:,0])
> plt.title("Evolution temporelle")
> plt.xlabel("Temps t (s)")
> plt.ylabel("Intensite i (A)")
> plt.plot(0,0.01,"ro")
> #plt.savefig("RLC-demarrage.eps")
> plt.show()
> ----------ijulia----------------
> @pyimport scipy.integrate as odeint
> function f(y,t)
>           if t<25
>             return [y[1],-8*y[0]+0.1*y[1]]
>           elseif 25<t<45
>                 return [y[1],-8*y[0]]
>           else
>                 return [y[1],-8*y[0]-0.1*y[1]]
>           end
> end;
> t=linspace(0,35,1000)
> y=linspace(0.01,0)
> y1=integrate.odeint(f,y,t)
>

Reply via email to