Matlab模拟三个天体运动

1 简介

这是一个三体运动模拟软件,描述自由空间中存在的两至三颗可视作质点的星体在相互之间的万有引力作用下所做的运动。基于牛顿经典力学原理,采用迭代法进行数值模拟,实时显示星体的位置以及轨迹。

2 部分代码

 %%%function varargout = Threebody(varargin)% THREEBODY MATLAB code for Threebody.fig%      THREEBODY, by itself, creates a new THREEBODY or raises the existing%      singleton*.%%      H = THREEBODY returns the handle to a new THREEBODY or the handle to%      the existing singleton*.%%      THREEBODY('CALLBACK',hObject,eventData,handles,...) calls the local%      function named CALLBACK in THREEBODY.M with the given input arguments.%%      THREEBODY('Property','Value',...) creates a new THREEBODY or raises the    %将选中的运动类型的数据传递到三行显示栏中去    %将代码中预的设数据写入第一行显示栏(第一颗星)    set(handles.Edit_m1,'String',num2str(star(1).M*10^(-19)));    set(handles.Edit_x1,'String',num2str(star(1).X));    set(handles.Edit_y1,'String',num2str(star(1).Y));    set(handles.Edit_z1,'String',num2str(star(1).Z));    set(handles.Edit_u1,'String',num2str(star(1).U*10^(-3)));    set(handles.Edit_v1,'String',num2str(star(1).V*10^(-3)));    set(handles.Edit_w1,'String',num2str(star(1).W*10^(-3)));    %将代码中预的设数据写入第二行显示栏(第二颗星)    set(handles.Edit_m2,'String',num2str(star(2).M*10^(-19)));    set(handles.Edit_x2,'String',num2str(star(2).X));    set(handles.Edit_y2,'String',num2str(star(2).Y));    set(handles.Edit_z2,'String',num2str(star(2).Z));    set(handles.Edit_u2,'String',num2str(star(2).U*10^(-3)));    set(handles.Edit_v2,'String',num2str(star(2).V*10^(-3)));    set(handles.Edit_w2,'String',num2str(star(2).W*10^(-3)));    %将代码中预的设数据写入第三行显示栏(第三颗星)    set(handles.Edit_m3,'String',num2str(star(3).M*10^(-19)));     set(handles.Edit_x3,'String',num2str(star(3).X));         set(handles.Edit_y3,'String',num2str(star(3).Y));       set(handles.Edit_z3,'String',num2str(star(3).Z));    set(handles.Edit_u3,'String',num2str(star(3).U*10^(-3)));     set(handles.Edit_v3,'String',num2str(star(3).V*10^(-3)));     set(handles.Edit_w3,'String',num2str(star(3).W*10^(-3)));    %保存数据    guidata(gcf,handles);end   %%% --------------------------------------------------------------------function normal_Callback(hObject, eventdata, handles)%%% hObject    handle to normal (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)view([-37.5,30]); %%% --------------------------------------------------------------------function XOY_view_Callback(hObject, eventdata, handles)%%% hObject    handle to XOY_view (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)view([-90,90]); %%% --------------------------------------------------------------------function YOZ_view_Callback(hObject, eventdata, handles)%%% hObject    handle to YOZ_view (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)view([-90,0]);%%% --------------------------------------------------------------------function ZOX_view_Callback(hObject, eventdata, handles)%%% hObject    handle to ZOX_view (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)view([180,0]);%%% --------------------------------------------------------------------function Version_Callback(hObject, eventdata, handles)%%% hObject    handle to Version (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)hs = msgbox({'软件操作说明:'   ''   '    Version: 1.0 '   ''   '    Author:'   ''   '    Chen Tianyang, Li Hao'   ''   '    Data:2017-10-25'   ''},'Version Information');%改变字体大小ht = findobj(hs, 'Type', 'text');set(ht,'FontSize',10);%改变对话框大小set(hs, 'Resize', 'on'); %%% --------------------------------------------------------------------function UserGuide_Callback(hObject, eventdata, handles)% hObject    handle to UserGuide (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)hs = msgbox({'软件操作说明:'   ''    ''},'UserGuide');%改变字体大小ht = findobj(hs, 'Type', 'text');set(ht,'FontSize',10);%改变对话框大小set(hs, 'Resize', 'on'); 

3 仿真结果

4 参考文献

[1]孙婷, 邢飞, 尤政. 一种基于天体运动学的星敏感器精度测量方法[J]. 清华大学学报:自然科学版, 2012, 52(4):6.

博主简介:擅长智能优化算法、神经网络预测、信号处理、元胞自动机、图像处理、路径规划、无人机等多种领域的Matlab仿真,相关matlab代码问题可私信交流。

部分理论引用网络文献,若有侵权联系博主删除。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

matlab科研助手

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值