(完整版)MATLAB行星运动仿真程序.doc

上传人:夏** 文档编号:549121642 上传时间:2023-03-14 格式:DOC 页数:3 大小:12.58KB
返回 下载 相关 举报
(完整版)MATLAB行星运动仿真程序.doc_第1页
第1页 / 共3页
(完整版)MATLAB行星运动仿真程序.doc_第2页
第2页 / 共3页
(完整版)MATLAB行星运动仿真程序.doc_第3页
第3页 / 共3页
亲,该文档总共3页,全部预览完了,如果喜欢就下载吧!
资源描述

《(完整版)MATLAB行星运动仿真程序.doc》由会员分享,可在线阅读,更多相关《(完整版)MATLAB行星运动仿真程序.doc(3页珍藏版)》请在金锄头文库上搜索。

1、clear all;close all;G=6.67*10-11;% The universal gravitational constantm = 1.989e30,3.5844e23,4.89868e24,5.974e24,6.5714e23,1.89854e27,5.68725e26,8.72204e25,1.02753e26;% An array of massesn = length(m); Number_of_planets = n% The number of massesx_p = 0,58340100000,1.07705e11,1.4959e11,2.27377e11,7.

2、77868e11,1.42709e12,2.87512e12,4.49668e12;% An array of x positionsy_p= 0,0,0,0,0,0,0,0,0;% An array of y positionsx_v = 0,0,0,0,0,0,0,0,0;% An array of x velocitiesy_v = 0,47856.46,34961.72,29780,23883.56,12924.52,9618.94,6789.84,5419.96;% An array of y velocitiesT= 365*24*60*60;%(2*pi*G*m(1)/(x_v(

3、1)3);dt=360*60*60*10;colordef black;ph = plot(x_p,y_p,.,MarkerSize,30);xlabel(distance(km);ylabel(distance(km);title(Planetary motion);for a=0:dt:1000*T%loop for all masses with respect to timefor k=1:n%loop for individual masses calculating neccessary quantitiesdx = x_p - x_p(k);% difference in x p

4、ositionsdy = y_p - y_p(k);% difference in y positionsmag = (dx.2 + dy.2).0.5;% magnitude of the distance between the 2 massesf = (G*m(k)*m)./(mag.2);% total forcefx_old =(f.*dx./mag);fx_old(k)= 0;fx = sum (fx_old);%Summing the total force in x direction for each planetfy_old =(f.*dy./mag);fy_old(k)=

5、 0;fy = sum (fy_old);%Summing the total force in y direction for each planeta_x = fx/m(k);% calculating acceleration change in x directiona_y = fy/m(k);% calculating acceleration change in y directionx_v(k) = x_v(k) + dt*a_x;% calculating velocity change in x directiony_v(k) = y_v(k) + dt*a_y;% calc

6、ulating velocity change in y directionx_p_new(k)= x_p(k)+dt*x_v(k);% calculating new x positionsy_p_new(k)= y_p(k)+dt*y_v(k);% calculating new y positionsendx_p=x_p_new;y_p=y_p_new;% overwriting old positions with new positionspause(0.1)plot(x_p,y_p,.,MarkerSize,30)axis(-(1015) 1015 -(1015) 1015)xlabel(distance(km);ylabel(distance(km);title(Planetary motion);drawnow% Plotting graphend

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 大杂烩/其它

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号