Graphing second order differential equation

조회 수: 5 (최근 30일)
Aleem Andrew
Aleem Andrew 2020년 2월 2일
답변: ag 2025년 3월 12일
I am attemping to graph the solution to the following system of differential equations.
mx¨ = −C*x*sqrt(x˙^2 + y˙^2)
my¨ = −C*y* sqrt(x˙^2 + y˙^2)− mg
Initial conditions: x(0) = 0; y(0) = 0; C: 4*10^-7 (constant)
x˙ : first derivative of x position
x¨: second derivative of x position
y˙^2: square of first derivative of y position
I have tried the following code but I get an error message saying that the code attempts to graph the solution outside the defined range (5,5.8) although the equations describe the parabolic motion of an object acted on by a drag force and should be defined from x=0 to the range.
syms x(t) y(t)
t0 = 0;
tf = 5400;
dx=diff(x,t);
dy=diff(y,t);
eq1 = dx*sqrt((dx*dx +dy*dy)) == diff(x,2);
eq2 = dy*sqrt((dx*dx +dy*dy))-50 == 10*diff(y,2);
vars = [x(t); y(t)];
[V,S] = odeToVectorField([eq1,eq2])
M = matlabFunction(V,'vars', {'t','Y'});
interval = [t0 tf];
y0 = [0 0 0 1];
ySol = ode45(M,interval,y0);
tValues = linspace(interval(1),interval(2),1000);
yValues = deval(ySol,tValues,1);
plot(tValues,yValues)

답변 (1개)

ag
ag 2025년 3월 12일
Hi Aleem, since the query has been answered on the following MATLAB answer post: https://www.mathworks.com/matlabcentral/answers/503268-graph-differential-equations-of-parabolic-trajectory-affected-by-drag-force?s_tid=answers_rc1-2_p2_BOTH, attaching here for better reach.

카테고리

Help CenterFile Exchange에서 Calculus에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by