How to solve coupled second order ODE using ode45

Hi, I'm trying to solve the following acceleration equations:
I currently have this code although I'm not sure if it's correct and when I ran it, MATLAB returned "Undefined function or variable 'xin'."
function Yd= tennispin(t,Y)
%constants
alpha = 80*pi/180;
r = 3.35;
w = 193;
A = 3.35^2*pi;
Cd = 0.55;
rho = 1.21;
m = 0.0577;
g = 9.81;
%equations
x = Y(1);
dYdt(1)= Y(2);
Y(2) = v*cos(theta)*sin(beta);
y = Y(3);
dYdt(3)= Y(4);
Y(4) = v*cos(theta)*cos(beta);
z = Y(5);
dYdt(5)= Y(6);
Y(6) = v*sin(theta);
dYdt(4) = ((rho*Y(6)^2*A*r*w*sin(alpha))/(m(4*r*w*sin(alpha)+2*Y(6))))-((Cd*rho*y(4)^2*A)/(2*m));
dYdt(2) = ((rho*Y(6)^2*A*r*w*cos(alpha))/(m(4*r*w*cos(alpha)+2*Y(6))))-((Cd*rho*y(4)^2*A)/(2*m));
dYdt(6) = -((rho*Y(4)^2*A*r*w*sin(alpha))/(m(4*r*w*sin(alpha)+2*Y(4))))-((rho*Y(2)^2*A*r*w*cos(alpha))/(m(4*r*w*cos(alpha)+2*Y(2))))-((Cd*rho*y(6)^2*A)/(2*m));
%initial conditions
a = Y(2);
a(0)= 28*cos(7.8*pi/180)*sin(10*pi/180);
b = Y(4);
b(0)= 28*cos(7.8*pi/180)*cos(10*pi/180);
c = Y(6);
c(0)= v*sin(7.8*pi/180);
x(0) = 8.97;
y(0) = 0;
z(0) = 0.5;
xin = [a(0), b(0), c(0), x(0), y(0), z(0)];
end
Thank you so much for your help!

Réponses (1)

Torsten
Torsten le 23 Mai 2016

0 votes

Take a look at the examples provided for the use of the ODE integrators in MATLAB:
Best wishes
Torsten.

Community Treasure Hunt

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

Start Hunting!

Translated by