Looks like a couple things going on here: - The error is due to a mix of hcat and vcat in the definition of f; replacing it with either *f(x,y)= [y;-w^2*sin(x)-u*w^2*cos(x); -2γ*y];* or *f(x,y)= [y, -w^2*sin(x)-u*w^2*cos(x), -2γ*y];* will fix this error. I predict other errors down the line: - f is a function of two arguments, but it is passed to ode45 with three. ode45 expects a function f=f(x,y) where y is a vector of length (in this case) 3, I guess. You could define f as a function of 3 arguments, then pass the anonymous function (x,y)->f(x,y,u) to ode4 - if U is a vector of length sizeU, you may get a BoundsError calling U[i] rather than U[j]
On Tuesday, March 10, 2015 at 8:33:10 AM UTC-4, Kacem HARIZ wrote: > > > > I got stuck by an error in Julia! please I need help! > > *here is the code:* > > > *w=1;* > *γ=0.01;* > *f(x,y)= [y;-w^2*sin(x)-u*w^2*cos(x) -2γ*y];* > > *for i=1 : numberOfStates* > * x0=Sx[i+2];* > * y0=Sy[i+2];* > * for j=1:sizeU* > * u=U[i];* > * t,NX=ODE.ode45(f(x,y,u),[0,0.1],[x0,y0])* > * end* > *end* > > with Sx and Sy two vectors of the same size, and U is a vector of size > sizeU. > > *and here is the error message:* > > mismatch in dimension 1 > while loading In[94], in expression starting on line 5 > > in cat at abstractarray.jl:631 > in hcat at abstractarray.jl:671 > in hvcat at abstractarray.jl:966 > in f at In[90]:3 > in oderkf at /home/juser/.julia/v0.3/ODE/src/ODE.jl:208 > in ode45_dp at /home/juser/.julia/v0.3/ODE/src/ODE.jl:303 > in anonymous at no file:10 > > > Best regards, > Kacem >