Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: MATLAB help! Ode45
Replies: 2   Last Post: Apr 10, 2013 6:50 AM

 Messages: [ Previous | Next ]
 Torsten Hennig Posts: 2,419 Registered: 12/6/04
Re: MATLAB help! Ode45
Posted: Apr 10, 2013 6:50 AM

> > Hi i am trying to solve a problem but i keep
> getting
> > error or cant run it at all....
> >
> > This is how far i have gotten
> >
> > function du = F(t,u)
> >
> > u = zeros(4,1);
> > u1 = u(1);
> > u2 = u(2);
> > u3 = u(3);
> > u4 = u(4);
> >
> > kx = 0.020;
> > ky = 0.065;
> >
> > du1 = u3
> > du2 = u4
> > du3 = -kx .* u3 .* (u3.^2+u4.^2).^1/2
> > du4 = -9.81 -ky .* u4 .* (u3.^2+u4.^2).^1/2
> >
> > du = [du1;du2;du3;du4];
> >
> > [t,u]=ode45('F',[0,30] [0,15] [0,19])
> >
> > What have i done wrong ?

>
>

Should be:

[t,u]=ode45(@F,[0 30], [0 15 0 19])

Put in separate .m-file:

function du = F(t,u)

u1 = u(1);
u2 = u(2);
u3 = u(3);
u4 = u(4);

kx = 0.020;
ky = 0.065;

du1 = u3;
du2 = u4;
du3 = -kx * u3 * (u3^2+u4^2)^1/2;
du4 = -9.81 -ky * u4 * (u3^2+u4^2)^1/2;

du = [du1;du2;du3;du4];

Best wishes
Torsten.

Date Subject Author
4/10/13 KIZHEN
4/10/13 Torsten Hennig
4/10/13 Torsten Hennig