0
votes

I'm completely stuck with one of my problem sets.

I'm supposed to solve the following system of ODEs using Matlab:

o'(u) = R-acos(u)/sqrt(b^2 + (R-acosu)^2)
e'(u) = Rcos(o)
n'(u) = Rsin(o)
R,a,b are constants
u goes from 0 to 2pi

I'm supposed to use the Runge Kutta method, which I haven't tried before. I've been at it for quite some time but don't even know where to start - which is why I don't really have any code to show you. I have been doing a lot of googleing but without results.

If anyone could give me a hand it would be much appreciated!

1

1 Answers

0
votes

Read the friendly manual available at mathworks on the use of ODE solvers and the syntax of calling a specific solver. The classical way here would be

function yprime = odefunc(u,y,R,a,b)
    o=y(1); e=y(2); n=y(3);
    oprime = R-a*cos(u)/sqrt(b^2 + (R-a*cos(u))^2);
    eprime = R*cos(o);
    nprime = R*sin(o);
    yprime = [oprime; eprime; nprime ];
end //function

and after defining initial conditions, time frames and parameters, call it as

[t,y] = ode45(@(t,y) odefunc(t,y,R,a,b), [t0, tf], [o0; e0; n0])