Search All of the Math Forum:

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

Topic: how to Solve coupled ODEs
Replies: 5   Last Post: Feb 12, 2013 11:07 AM

 Messages: [ Previous | Next ]
 Torsten Posts: 1,717 Registered: 11/8/10
Re: how to Solve coupled ODEs
Posted: Feb 7, 2013 3:15 AM

"Henry" wrote in message <keujnd\$h64\$1@newscl01ah.mathworks.com>...
> Hi there,
>
> I'm having a hard time solving a set of 2 coupled ODEs:
>
> dx/ds = 1/x * [y* (d + y/s) - a*x*f]
> dy/ds = 1/x * [-y * (b + y) * f] - y/s - c
>
> where f = sqrt(x^2 + y^2*(e + y)), and all constants are vectors of (100 x 1). The independent variable is "s".
>
> %----------------------------------------------------------------------
> global a b c d e
> y = ode45(@odeeqns, s, [1 1])
>
> function dyds = odeeqns(s,y)
> global a b c d e
> dyds(:,1) = 1./y(1) .*(y(2) .* (d + s ./ y(2)) - a .* y(1) .* sqrt(y(1).^2 + (e + y(2)).^2));
> dyds(:,2) = - (y(2) .* (b + y(2)) .* sqrt(y(1).^2 + (e + y(2)).^2))./y(1) - y(2)./s - c;
> return
> %----------------------------------------------------------------------
>
> Thanks!

Take a look at example 1 under
http://www.mathworks.de/de/help/matlab/ref/ode23.html
and you'll recognize the two (or three) errors you made in your small piece of code
from above.

Best wishes
Torsten.

Date Subject Author
2/7/13 Torsten
2/8/13 Torsten
2/12/13 Torsten