Sorry I forget the function and following the example it should be for me :
y=[0.01,0]

function on_button_press(event)

t_sim = linspace(0, 50, 200)
x, y = event[:xdata], event[:ydata]
x₀ = [x, y]
ys = integrate.odeint(f, x₀, t_sim)
plt[:plot](ys[:,1], ys[:,2], "k-", markersize=10) # path
plt[:plot]([ys[1,1]], [ys[1,2]], "o", markersize=10) # start
plt[:plot]([ys[-2,1]], [ys[-2,2]], "s", markersize=10) # end
    
fig[:canvas][:draw]()

end



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 integrate
> 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