ode45 projectile motion with drag in Y direction. help im desperate
9 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
tspan = [0:.001:3];
IC = [0,0];
[t,y] = ode45(@f,tspan,IC);
ydot = y(:,1);
ydub = y(:,2);
v0x = 10./sqrt(2);
x0 = 0;
y0 = 0;
x = x0 + v0x.*tspan + 0;
figure(1);hold on;axis on;
plot(x,y);
legend('ydot','ydub')
title('Projectile Motion')
xlabel('X-Position')
ylabel('Y-Position')
function ydub = f(t,y);
% [y] = [y(1), y(2)] = [y1, y2] = [ydot, ydub]
c = 0;
p = 0;
m = 1;
g = 9.8;
ydub = [y(2); (c.*(y(1).^p))./m - g];
end
I am trying to graph the position of a projectile with drag in the Y direction, but not in the X direction, in 2D on the x-y plane, using ODE45 to find the position equation. The equation of motion I obtained is Ydoubledot = (((C)*Ydot^p)/m) - g. My graph does not look right, I think it is supposed to go up then down. Attached are pics of the problem statement, and the graph I am getting. Help im dying. Thanks.
1 comentario
Respuestas (1)
darova
el 8 de Mzo. de 2019
function temp
tspan = 0:.001:1;
x0 = 0;
y0 = 0;
a = 45;
v0x = 10*cosd(a);
v0y = 10*sind(a);
u0 = [x0 y0 v0x v0y];
[t,y] = ode45(@f,tspan,u0);
X = y(:,1);
Y = y(:,2);
% vx = y(:,3);
% vy = y(:,4);
plot(X,Y)
axis equal
legend('Trajectory');
title('Projectile Motion')
xlabel('X-Position')
ylabel('Y-Position')
end
function ydot = f(t,u)
c = 0.5;
p = 2;
m = 1;
g = 9.8;
% u(1); % x
% u(2); % y
ydot(1,1) = u(3); % vx
ydot(2,1) = u(4); % vy
ydot(3,1) = -c/m*u(3).^p; % ax
ydot(4,1) = -c/m*u(4).^p -g; % ay
end
0 comentarios
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!