Error while solving differential equations matlab -


i'm looking way solve differential equations.

equations

i've got small experience solving type of equations, here's noob code

function lab1() [t,h]=ode45('threepoint', [0 1000], [0 0.25]); plot(t, h);    function f = threepoint(x, y) %threepoint summary of function goes here %   detailed explanation goes here m = 15000; r1 = 0.1; r2 = 0.1; p1 = 0.1; p2 = 0.1; b = 4; rbk = 0.5; f=[x(6);     x(7);     x(8);     x(9);     x(10);     (-x(6) / (m * sqrt( x(6)*x(6) + x(7)*x(7)))) * (r1 + r2) + (cos(x(3))/m) * p1 + (cos(x(3))/m) * p2;     (-x(7) / (m * sqrt( x(6)*x(6) + x(7)*x(7)))) * (r1 + r2) + (cos(x(3))/m) * p1 + (cos(x(3))/m) * p2;     -(m/i) - (1/i1)* (b/2 + y(1))*p1 + (1/i2)*(b/2+y(2))*p2;     (rbk/i1)*(p1-r1);     (rbk/i2)*(p2-r2);     ];   end 

while running these functions have got such errors

index exceeds matrix dimensions.

error in threepoint (line 11) f=[x(6);

error in odearguments (line 87) f0 = feval(ode,t0,y0,args{:}); % ode15i sets args{1} yp0.

error in ode45 (line 113) [neq, tspan, ntspan, next, t0, tfinal, tdir, y0, f0, odeargs, odefcn, ...

error in lab1 (line 2) [t,h]=ode45('threepoint', [0 1000], [0 0.25]);

can please show me mistaken , how can fix these errors? thank in advance!

please take close @ help ode45. admit part of usage might not clear, take @ doc ode45 too.

here's essence of problem. want solve differential equation of 10 variables, each function of t. so, how general solver ode45 know needs work 10-component arrays @ each time step? place can: initial value!

here's how you're calling ode45:

[t,h]=ode45('threepoint', [0 1000], [0 0.25]); 

the second array, y0, initial value. clear docs. since you're supplying 2-element vector, ode45 smartly realizes have 2 equations. when try use y(6) , other high-index values in threepoint(), error you're getting: index exceeds matrix dimensions. because index, 6, exceeds size of array, 2.

you need use initial values proper size (length-10 in specific case) in order inform solver dimensions of problem. if ode45 assert size of equations somewhere, really have provide initial values 10 components of solution.