my m-file looks like
function xp=F(t,x) xp=zeros(5,1); m=1; w=1; h=.5; y=.01; xp(1)=-m*(w^2)*(x(2)^3)*(-(h*y)/(2*w*m))*24*x(3); xp(2)=x(1); xp(3)=2*w*x(4); xp(4)=-x(2)*w*(1+((12*x(2)*x(2))/(m*w*w)))*x(3)+w*x(5); xp(5)=-x(2)*w(1+((12*x(2)*x(2))/(m*w*w)))*x(4);
and when i set m,w,y,and h then run the code
[t,x]=ode45('F',[0,10],[0,1,.5*((1+((12*x(2)*x(2))/(m*w*w)))^(-.5)),0,.5*((1+((12*x(2)*x(2)) /(m*w*w)))^(.5))]);
i get the errors
??? Index exceeds matrix dimensions. Error in ==> F at 11 xp(5)=-x(2)*w(1+((12*x(2)*x(2))/(m*w*w)))*x(4); Error in ==> odearguments at 98 f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0.
Error in ==> ode45 at 172 [neq, tspan, ntspan, next, t0, tfinal, tdir, y0, f0, odeArgs, odeFcn, ...
Best Answer