[julia-users] Dimension mismatch error in Julia!
*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:sizeof(Sx)* *x0=Sx[i+2];* *y0=Sy[i+2];* *for j=1:sizeU* *u=U[i];* *t,NX=ODE.ode45(f,[0,0.1],[x0,y0])* *end* *end* with Sx and Sy vectors of the same size, and U an other vector of size sizeU. *and here is the error message:* mismatch in dimension 1 while loading In[69], 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[69]: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 Does anyone know how to fix it, please let me know, I'd be very grateful!
[julia-users] Dimension mismatch error in Julia!
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
Re: [julia-users] Dimension mismatch error in Julia!
It is more helpful if you can provide a self contained example that we can run. However, I think you've been bitten by our white space concatenation. When you define f, the second element is written *-w^2*sin(x)-u*w^2*cos(x) -2γ*y* *but I think that is getting parsed as* *hvcat(**-w^2*sin(x)-u*w^2*cos(x), -2γ*y**)* *if instead you had a space after the minus, it would work. Like* *-w^2*sin(x)-u*w^2*cos(x) - 2γ*y* *That is a bit unfortunate and something that is heavily discussed right now.* 2015-03-10 5:17 GMT-04:00 Kacem HARIZ : > *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:sizeof(Sx)* > *x0=Sx[i+2];* > *y0=Sy[i+2];* > *for j=1:sizeU* > *u=U[i];* > *t,NX=ODE.ode45(f,[0,0.1],[x0,y0])* > *end* > *end* > > with Sx and Sy vectors of the same size, and U an other vector of size > sizeU. > > *and here is the error message:* > > mismatch in dimension 1 > while loading In[69], 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[69]: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 > > Does anyone know how to fix it, please let me know, I'd be very grateful! >
Re: [julia-users] Dimension mismatch error in Julia!
It would be helpful if you could post an example which runs with just copy-paste into the REPL. On Tue, 2015-03-10 at 10:55, 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