What do you mean to change f(y,t) ?
and what is 1-base arrays ? (does it mean it starts to 1 ?)
I modify my code can you ajust it if you see problems ?
------------------------------------------------------------------------
@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;
xₜ=linspace(0,35,1000)
y₀=25
yₜ=integrate.odeint(fₜ,y₀,xₜ)
Le lundi 20 juin 2016 21:38:56 UTC+2, Michele Zaffalon a écrit :
>
> And remember to change your f(y,t) because Julia has 1-based arrays.
>
> On Mon, Jun 20, 2016 at 9:32 PM, Michele Zaffalon <[email protected]
> <javascript:>> wrote:
>
>> Also linspace(0.01,0) is not the same as [0.01,0]
>>
>> On Mon, Jun 20, 2016 at 8:15 PM, Henri Girard <[email protected]
>> <javascript:>> wrote:
>>
>>> After correction still doesn't work.
>>> I have this function from another programme which is working, i wonder
>>> if it's not my odeint(f,y,t) which is wrong ?
>>>
>>>
>>> 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)
>>>>
>>>
>>
>