"gati " <email@example.com> wrote in message news:firstname.lastname@example.org... > HI, I am using an ode function having three differntial equations in u(1), > u(2), (3) using function f=treat(t, u), Now when i use if function as if > (u(2)>1000) c=1; else (u(1)<=100) c=0; end i am getting the following > error Attempted to access u(2); index out of bounds because numel(u)=1. > Error in ==> treat at 31 if (u(2)>1000) Please tell me. thanks
My guess is that the initial condition vector you passed into the ODE solver has only 1 element. If you've got three ODEs in three variables, you need a 3-element initial condition vector.