Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

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


Math Forum » Discussions » Software » comp.soft-sys.matlab

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

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Torsten Hennig

Posts: 2,419
Registered: 12/6/04
Re: MATLAB help! Ode45
Posted: Apr 10, 2013 5:54 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

> 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 ?



[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.



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.