how to numerically solve a coupled ode?

Hi,
Please help to solve the following ODE or numerically solve it (get theta(t) and phi(t)):
ODE 1 :
thetaDoubleDot = ((36297*cos(theta))/2 + (80*sin(phi)*(- CA*cos(phi - theta)*phiDot^2 + 4*cos(theta)*thetaDot^2 + CA*phiDoubleDot*sin(phi - theta)))/cos(phi - theta))/((320*sin(phi)*sin(theta))/cos(phi - theta) - 1300/3)
ODE 2:
phiDoulbeDot = (sin(phi - theta)*((1300*thetaDoubleDot)/3 + (36297*cos(theta))/2 + (80*sin(phi)*(- CA*sin(phi - theta)*phiDot^2 + 4*sin(theta)*thetaDot^2 + 4*thetaDoubleDot*cos(theta) + 981/100))/sin(phi - theta)))/(80*CA*cos(phi - theta)*sin(phi))
The thing is that they are coupled. As in the first ODE contain phiDoubleDot and the second ODE contain thetaDoubleDot.
Regards,

 采纳的回答

Use the Symbolic Math Toolbox for this.
First, declare all the appropriate variables as functions of time:
syms theta(t) phi(t) CA T Y
Then define the derivatives as:
Dtheta = diff(theta);
D2theta = diff(theta,2);
Dphi = diff(phi);
D2phi = diff(phi,2);
and make the appropriate substitutions in these equations:
thetaDoubleDot = ((36297*cos(theta))/2 + (80*sin(phi)*(- CA*cos(phi - theta)*phiDot^2 + 4*cos(theta)*thetaDot^2 + CA*phiDoubleDot*sin(phi - theta)))/cos(phi - theta))/((320*sin(phi)*sin(theta))/cos(phi - theta) - 1300/3)
phiDoulbeDot = (sin(phi - theta)*((1300*thetaDoubleDot)/3 + (36297*cos(theta))/2 + (80*sin(phi)*(- CA*sin(phi - theta)*phiDot^2 + 4*sin(theta)*thetaDot^2 + 4*thetaDoubleDot*cos(theta) + 981/100))/sin(phi - theta)))/(80*CA*cos(phi - theta)*sin(phi))
so that they are in the form of:
Eqn1 = D2theta == ((36297*cos(theta))/2 + ...
Eqn2 = D2phi == (sin(phi - theta)* ...
Since the objective is to solve them numerically, then use odeToVectorField and matlabFunction:
[VF,Subs] = odeToVectorField(Eqn1,Eqn2)
odefcn = matlabFucntion(VF, 'Vars',{T,Y,CA})
Then it should be possible to use ‘odefcn’ with ode45 and the others.
I leave the details to you.
.

更多回答(0 个)

类别

产品

版本

R2020a

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by