Help me understand!
4 次查看(过去 30 天)
显示 更早的评论
I am presented with a task of simulating the movement of three bodies with a constant mass using Newton's laws.
The task is very easy to follow and I have no trouble understanding it, until it comes to solving the differential equation
using Runge-Kutta, where M is the mass of a body,
is the second derivative of the position, namely, the acceleration and F is the force applied on M due to the two other masses.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/894335/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/894340/image.png)
Please refer to task number 3 below
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/894345/image.png)
Where equation 3 is
I am finding it particularly difficult to understand why the right hand of the equation is a column consisten of what appears to be the velocity V for each body and the acceleration
.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/894350/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/894355/image.png)
I would highly appreciate any guidance to the interpertation of the task!
2 个评论
采纳的回答
AndresVar
2022-2-14
编辑:AndresVar
2022-2-16
Equation 3 is a 2nd order system p''=..., the RK3 is given for 1st order p'=...(see it's first difference
) =..)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/894425/image.png)
See for example equation 14 here: part1.pdf (nyu.edu)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/894430/image.png)
you can see how order is reduced by introducing firts time derivatives (V's) as new variables
2 个评论
AndresVar
2022-2-16
f = Y = RHS(t,X). The RHS you commented above looks good just make sure P1=X(1), V1=X(2)... etc as defined in task#1. You didn't say, but I guess velocity is constant?
% at t0
Y0 = RHS(t0,X0)
% one step later Y(t0+h)=Y1
K1=h*Y0;
K2=h*RHS(t+h/2,Y0+h/2);
K3=...
Y1 = Y0 + 1/6(K1+4*K2+K3)
% two steps later Y(t0+2h)=Y2
K1=h*Y1;
K2=...
K3=...
Y2 = Y1 + 1/6(K1+4*K2+K3)
code repeats, so just turn it into a loop for N steps
h = 0.01;
t(1) = 0;
Y(1)=RHS(t0,X0) %initial
for ii = 1:N
t(ii+1) = t(ii)+h
K1 =...
K2 =...
K3 =...
Y(ii+1) = Y(ii)+1/6(K1+4*K2+K3);
end
plot the forces vs time to see if they behave nicely... if not then you can play with the step size h
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Ordinary Differential Equations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!