Hi Lytu,
sorry, I just saw this post after answering in the other thread...
I think one problem with your code is that in (recent versions of) ODE.jl
the order of the arguments y and t is reversed. Instead of
tout, yout = ode45(fct, t, y0)
try
tout, yout = ode45(fct, y0, t)
Best,
Alex
On Friday, 12 June 2015 10:00:29 UTC+2, Lytu wrote:
>
> Hello,
>
> I have a question about the package ODE in Julia.
> In Matlab, when i use *[tout, yout] = ode45('fct', t, y0);* it works but
> when i try to do the same thing in Julia < *tout, yout = ode45(fct, t,
> y0)* > , sometimes it works but with different results *tout, yout* and
> with a different plot (different from the one i had in Matlab or different
> from the analytic solution plot) or it completely doesn't plot.
>
> Can someone please explain to me what's going on? Here below, i added an
> example of what i'm talking about :
> In Matlab, this example below works : function dydt = fct(t, y) dydt = -
> 2*y*t; end % SCRIPT MAIN t = [0: 0.1: 1]; y0 = 2; [tout, yout] =
> ode45('fct', t, y0); plot(tout, yout, 'b'); %numeric solution plot(t,
> y0.*exp(-t.^2), 'r'); %analytic solution But when i try to do the same
> thing in Julia, it doesn't work, i mean there's no plot for the numeric
> solution, see the code below in Julia: function fct(t, y) dydt = - 2*t*y
> return dydt end
> # MAIN using ODE using PyPlot t = [0:0.1:1] y0 = 2 tout, yout = ode45(fct,
> t, y0) plot(tout, yout, "b") # plot the numeric solution plot(t,
> y0.*exp(-t.^2), "r") # plot the analytic solution The numeric solution plot
> nothing, there's only the plot of the analytic solution.
>
> Thank you
>